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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

utcDateTime issue

(0) ShareShare
ReportReport
Posted on by 75

FO form data

pastedimage1677836150902v1.png

I need same dates but when running following code in runnable class

select hRMRecruitingTable
            where hRMRecruitingTable.hrmRecruitingId == 'FA'
            && hRMRecruitingTable.kSPEndDateTime >= DateTimeUtil::applyTimeZoneOffset(hRMRecruitingTable.kSPEndDateTime, DateTimeUtil::getUserPreferredTimeZone());

        info(strFmt("%1, %2" ,hRMRecruitingTable.kSPEndDateTime 
            ,DateTimeUtil::applyTimeZoneOffset(hRMRecruitingTable.kSPEndDateTime, DateTimeUtil::getUserPreferredTimeZone())));

I got 2 different dates

pastedimage1677835984517v1.png

Any solution?

  • Suggested answer
    Martin Dráb Profile Picture
    241,511 Most Valuable Professional on at

    That's the expected behaviour. One value is in UTC and one in user preferred timezone. They'll be the same only if the current timezone offset of user preferred timezone is zero.

  • Mohit Rampal Profile Picture
    12,573 Moderator on at

    Hi Ashraf, In addition to Martin's response, you can check this thread as well. Martin has explained in detail

    community.dynamics.com/.../utcdatetime-and-timezone-offsets

  • Ashraf_ahk Profile Picture
    75 on at

    I resolved the issue by using following techniques:

    1:Functional

    Set Time Zone

    OMLegalEntities

    SysUserSetup

    2:Technical

    utcdatetime currentDateTime = DateTimeUtil::getSystemDateTime();
    
    select hRMRecruitingTable
                where hRMRecruitingTable.hrmRecruitingId == 'FA'
                && hRMRecruitingTable.kSPEndDateTime >= currentDateTime;
    
            info(strFmt("%1, %2" ,hRMRecruitingTable.kSPEndDateTime 
                ,DateTimeUtil::applyTimeZoneOffset(hRMRecruitingTable.kSPEndDateTime, DateTimeUtil::getUserPreferredTimeZone())));

    Set FormDateTimeControl property -> Timezone Preference: User

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
Martin Dráb Profile Picture

Martin Dráb 536 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 320 Super User 2026 Season 2

#3
CU-1234529-002 Profile Picture

CU-1234529-002 210

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans