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

Notifications

Announcements

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 843
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
    238,050 Most Valuable Professional on at
    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.
  • Shooowtek Profile Picture
    843 on at
    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
    238,050 Most Valuable Professional on at
    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.

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

News and Announcements

Season of Giving Solutions is Here!

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 678 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 407 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 283 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans