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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
11manish Profile Picture

11manish 103

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 76 Super User 2026 Season 1

#3
Martin Dráb Profile Picture

Martin Dráb 59 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans