Skip to main content

Notifications

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 785
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?
  • Martin Dráb Profile Picture
    234,031 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
    785 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
    234,031 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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Product updates

Dynamics 365 release plans