Asked by:
TimeZone difference while retrieving Datetime field

Question
-
Hi,
When i am retrieving CRM Datetime field(in C#) when it is having 12 AM, means 0:00 then i am getting one hour previous time. If it is not 12 AM then i m getting correct time. If i am adding time zone bias then the problem is solving for 12AM, but except this time remaining all i am getting problem. If any one knows please let me know what is the problem.
Thanks,
Sravan J
- Edited by sravan J Wednesday, January 29, 2014 7:40 AM modify
Wednesday, January 29, 2014 7:39 AM
All replies
-
are you getting value in utc format then you have to add time difference in your code.
Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"
- Proposed as answer by Mr. Santosh Bhagat Wednesday, January 29, 2014 8:11 AM
Wednesday, January 29, 2014 8:11 AM -
Hi Santosh,
Thanq for your reply. I added the difference then it is working only for 12AM. If i got any time other than 12AM then the difference is adding for remaining times.
Now i added time difference only for 12AM. Now it is working fine. But my doubt is why we are getting this problem, and any other solution for that?
- Edited by sravan J Wednesday, January 29, 2014 9:13 AM modify
Wednesday, January 29, 2014 9:10 AM -
Hi Sravan,
Please refer this post from powerobjects
http://www.powerobjects.com/blog/2012/06/07/crm-2011-truths-about-datetime/
- CRM DateTime always comes with time component. There is a setting in creating a DateTime field that defines date only, but all that does is default the time to midnight local time
- DateTime is saved in database as UTC time
- DateTime in CRM UI is always shown based on user’s local time zone. This is true even if UI is only showing the date component. This leads to following effect:
- If user in CST enters contact’s birthdate as 2/2/1980, this is saved as 2/2/1980 05:00 in DB
- If user in PST views the contact record, he/she will see the birthdate as 2/1/1980 (because local time for the user will be 2/1/1980 22:00)
- DateTime retrieved through CRM Web Services is always UTC time
- DateTime set through CRM Web Services is user’s local time zone by default
- Note that extra care must be taken to understand whether the call is done with the calling user or a service user
- DateTime set through CRM Web Services can be defined to be UTC instead
- DateTime queried directly from SQL table or base view returns UTC
- DateTime queried from filtered view returns users local time
for mode detail you can refer this
Hope it helps.
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Mohammad Yusuf Ansari http://microxrm.blogspot.in
- Proposed as answer by HIMBAPModerator Wednesday, January 29, 2014 10:36 AM
Wednesday, January 29, 2014 10:04 AM -
HI Sravan,
I tested the same work fine in my case i have add time difference like datefield.addminutes(330) from India in my scenario.
Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"
Wednesday, January 29, 2014 10:55 AM