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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

UTC date conversion issue

(1) ShareShare
ReportReport
Posted on by 815
Hi,
I have a problem with getting utc dates from standard tables and putting them on custom ssrs report.
For example: when I get the date 25.01.2024 00:00:00 they always get the value minus two hours 24.01.2024 22:00:00.
Probably this is related to time from the server and time zone differences, but I can't deal with it to permanently solve this problem.
So far, I have tried converting in different directions:

DateTimeUtil::newDateTime(date)
DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(utcDate,DateTimeUtil::getUserPreferredTimeZone()))
clrSystemDateTime2UtcDateTime(date)
 
Can anyone help?
I have the same question (0)
  • Martin Dráb Profile Picture
    235,838 Most Valuable Professional on at
    UTC date conversion issue
    There is no thing like "the date reduced by two hours", because a date doesn't have a time. You must mean a datetime value. The value in database should be in UTC and you must use applyTimeZoneOffset() to convert it from UTC to user's timezone. But it's also possible that it's not in UTC because it was saved by buggy code. Check whether the value in DB is correct if applying the timezone doesn't work correctly.
  • Shooowtek Profile Picture
    815 on at
    UTC date conversion issue
    Fields in the standard table are "FieldUTCDateTime", but my fields in the report class are of type "Date". 
     
    I getting the utcDateTime from the system and compare it with the date entered by the user. To do this, I convert date types “Date to utcDateTime using DateTimeUtil::newDateTime(date)

    The problem is that on the development machine everything works OK. But already on the test and production environment I get the date reduced by two hours.
  • Martin Dráb Profile Picture
    235,838 Most Valuable Professional on at
    UTC date conversion issue
    What is the type of the field? date or utcdatetime? You mentioned "UTC dates", which doesn't make a good sense, and your code seems to work with dates rather than utcdatetimes. On the other hand, 24.01.2024 22:00:00 isn't a date, it's date and time. But maybe you got that just because you're interpreting the date in a wrong way.
     
    If it's a date and you want to show it as a date, then forget the time part and all the conversions.
     
    It it's a utcdatetime, timezone handling is needed (and we'll discuss it in more details if needed).
     
    The first and the third of your conversions functions aren't useful in either case.

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…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 708 User Group Leader

#2
Martin Dráb Profile Picture

Martin Dráb 589 Most Valuable Professional

#3
Yng Lih Profile Picture

Yng Lih 553

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans