Skip to main content



No record found.

Dynamics 365 general forum
Suggested answer

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

Posted on by 35

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.

  • Suggested answer
    Mohamed GRAIB Profile Picture
    Mohamed GRAIB 2,496 Super User 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();


           // 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.

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,068 Super User 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.


    Abdul Wahab
    Power Platform/Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Skype: abdul.wahabubit

Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,682 Super User

Martin Dráb Profile Picture

Martin Dráb 225,000 Super User

nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans