Skip to main content

Notifications

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?

  • Ashraf_ahk Profile Picture
    Ashraf_ahk 75 on at
    RE: utcDateTime issue

    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

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: utcDateTime issue

    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

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: utcDateTime issue

    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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans