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

Notifications

Announcements

No record found.

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

I have the same question (0)
  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at

    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
    2,504 Moderator on at

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
Pallavi Phade Profile Picture

Pallavi Phade 32

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans