Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Posting Date values through Web API displaying incorrectly in CRM

Posted on by 2,095

Hi all

I've got a question. We are doing a website integration from an online form that has a date and time field passed through to a date and time field (set to timezone independent) in the CRM. 

We are using the CRM REST builder to build the create request and when executing it seems fine. The only problem is that when for example I set the start date and time on the website form to

23/05/2018 9:00am

It passes through to the CRM as 22/05/2018 11:00pm. I understand CRM stores date and time as UTC but I would of expected setting the field as timezone independent would mean it would no longer convert the time to the user local time when viewing in the CRM. The code snippet the REST builder generates is:

startdateandtime = new Date("05/23/2018 09:00:00").toISOString();

But when viewing the CRM entity record it's set it to 22/05/2018 11:00pm. Any help would be greatly appreciated.

Kind regards

Mike

*This post is locked for comments

  • MikeC282 Profile Picture
    MikeC282 2,095 on at
    RE: Posting Date values through Web API displaying incorrectly in CRM

    Thanks all,

    Both solutions worked.

  • Suggested answer
    keyur7379 Profile Picture
    keyur7379 900 on at
    RE: Posting Date values through Web API displaying incorrectly in CRM

    Hi,

    please use this.

    DateTime date2 = utcDate1.ToLocalTime();

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Posting Date values through Web API displaying incorrectly in CRM

    Hi Mike,

    Time-Zone Independent format saves in UTC on the backend without converting the time-zone.

    Try changing the date field to UTC and post the UTC value to the date time field in Web API.

    DateTime date = new DateTime(2018, 5, 23, 9, 0, 0).ToUniversalTime();

    Hope this helps.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans