Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Field Datetime x Convert Date

(0) ShareShare
ReportReport
Posted on by 692

Good morning everyone,

I'm using GetMonth () to pick up the value of the month to compose a date

Var Current_Date = new Date ();
Var month = (Current_Date.getMonth () + 1) + "";

I saw that the getMonth method starts with what is Month 1 'January', 1 'February', 2 'March' and so on.

However I need to set a date in a field with the month of March, and it arrow 3 for the month that in the method is April, but in the CRM it arrow as if it were March.

Could someone tell me what it could be? Is there a way to convert this?

Thank you

*This post is locked for comments

  • Verified answer
    Gopalan Bhuvanesh Profile Picture
    Gopalan Bhuvanesh 11,401 on at
    RE: Field Datetime x Convert Date

    getMonth(), would return between 0 and 11 (Jan-Dec),

    For comparison and manipulation convert the date to UTC, as the dates you get in JS would be UTC.

    www.w3schools.com/.../js_date_methods.asp

  • RE: Field Datetime x Convert Date

    Thanks for the answer

    I understand more if I give a setValue via javascript, it will be 02 (March), but the month will set to 3 and I need to set as 4 (April), future month, in this case I need to set 1 more correct?

  • Suggested answer
    Mihir Maruti Kadam Profile Picture
    Mihir Maruti Kadam 702 on at
    RE: Field Datetime x Convert Date

    In JavaScript, month start with 0(January). Do not add +1 in the month while setting value for the date.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,430 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans