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

Notifications

Announcements

No record found.

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?

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,722 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,565 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

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
Martin Dráb Profile Picture

Martin Dráb 687 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 403 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans