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 CRM (Archived)

crm 2013 ToUniversalTime() issue

(0) ShareShare
ReportReport
Posted on by

Hi,

Is there a issue of ToUniversalTime() in crm 2013?

Because when i converting Appointment scheduledstart to universal time value of sql server in my code,It gives me wrong output.Below is my code.

DateTime scheduleEmd = Convert.ToDateTime(objAppointment[count].ScheduledEnd);

node.SelectSingleNode("Form/scheduledend/Value").InnerText = scheduleEmd.ToUniversalTime().ToString();

Thanks.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Here in my case it simply retrieve the converted UTC timezone value

    So, why should i convert the value to UTC?

  • Suggested answer
    Community Member Profile Picture
    on at

    What time does it show? Do you see if there is any relation to the timezone of the MS Application Servers?

    Harihar

  • Hosk Profile Picture
    on at

    Where are you using this code?

    Why are you converting the time?  isn't the time already converted on the form to the datatime you have specified in your personal settings?

    What is the time difference?

  • Community Member Profile Picture
    on at

    Is it because i don't use impersonation in the XRM service?

  • Suggested answer
    Hosk Profile Picture
    on at

    it would help if you gave us more details

    where is the code running

    what is happening

    what you think should happen.

    CRM version

    your investigation and findings

    if you are using a plugin, it doesn't convert the data into UTC like CRM website does because CRM converts the data into the date format settings specified in your options

    DateTime stored values are always in UTC

    DateTime fields in CRM UI show the right values but when you retrieve them by code are not the same? The automatic UTC conversion made by CRM is the reason.

    read these blog posts to understand

    www.powerobjects.com/.../crm-2011-truths-about-datetime

    www.develop1.net/.../Dynamics-CRM-DateTimes-the-last-word.aspx

  • Suggested answer
    Magor Kovacs Profile Picture
    1,835 on at

    Hello kandarp,

    Unless we are missing some crucial piece of info here, you should not need the code to convert the time. In the database it's stored in UTC and is automatically converted based on the personal settings of the user displaying it.

    Please let us know what the aim of the above code is, what it tries to achieve.

  • Community Member Profile Picture
    on at

    I mean when we are retrieve the data from the database through the crm service it gives me the datetime UTC and in crm 4.0 it directly converts the data(datetime) as per user time zone.I don't know how it is doing?

  • Suggested answer
    Community Member Profile Picture
    on at

    Kandarp,

    I believe there are settings for individual user to set the time zone. Not sure if this is the case in your situation.

    I am pretty new to this application and hence take with a pinch of salt.

    Kind regards,

    harihar

  • Suggested answer
    Morne Wolfaardt Profile Picture
    on at

    DateTime awnserDate = question.awnser.value().toLocalDateTime()

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans