web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

How to get value of date only field . (11/1/2022)

(0) ShareShare
ReportReport
Posted on by

I'm getting this error while applied java script on getting month and year from date only field.

Value should be of type: Date: Parameter Name: value

please help me to resolve this.

I have the same question (0)
  • Suggested answer
    Abdul Wahab Profile Picture
    Moderator on at
    RE: How to get value of date only field . (11/1/2022)

    Hi Diksha Kanwar,

    What code you are using right now to get the value? can you please share it?

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform/Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

  • Suggested answer
    Mohamed GRAIB Profile Picture
    Moderator on at
    RE: How to get value of date only field . (11/1/2022)

    Hi Diksha,

    Please try this function,

    function getDateField(e){

       // Get the Form Context

       var formContext = e.getFormContext();

       // Get the value of the Opportunity Est. Close Date

       var date = formContext.getAttribute("estimatedclosedate").getValue();

       if (date != null) {

           var day = date.getDate();

           var month = date.getMonth();

           var year = date.getFullYear();

           month++;

           // Add leading 0's to single digit days and months

           if (day < 10) {day = "0" + day;}

           if (month < 10) {month = "0" + month;}

           // Create a variable with the formatted date as MM/DD/YYYY

           var formattedDate = month + "/" + day + "/" + year;

           // Create a variable with the formatted date as DD/MM/YYYY

           //var formattedDate = date + "/" + month + "/" + year;

       }

    }

    Please mark the answer as verified if that's resolve your problem.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans