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

Community site session details

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

How to get server date using x++ code.

(0) ShareShare
ReportReport
Posted on by 166

Hi Everyone,

A small request. How can I get server date using x++ code.

Thanks.

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: How to get server date using x++ code.

    Hi Apratim,

    You can make use of DateTimeUtil class.

    DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());

    Thanks,

    Girish S.

  • Suggested answer
    Vasileios Papoglou Profile Picture
    104 on at
    How to get server date using x++ code.
    systemDateGet: Retrieves the session date, if it has been set.
    Remarks: The today function returns the system date.
     
    What's more in "Modules > Common > Common > Session date and time" there is Current date which is non editable and Session date which is editable.
    I investigated the code used for changing session date in SystemDate form and method updateCurrentDateTimeValues():
    currentDate.dateValue(DateTimeUtil::getToday(preferredTz));
    currentTime.value(DateTimeUtil::getTimeNow(preferredTz));
    currentTimeZone.selection(preferredTz);
    
    sessionDate.dateValue(DateTimeUtil::date(sessiondatetime));
    sessionDate.value(DateTimeUtil::time(sessiondatetime));
    sessionTimeZone.selection(preferredTz);
    It seems that the non editable date of the System comes from getToday(TimeZone) method.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

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

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 588

#3
Martin Dráb Profile Picture

Martin Dráb 542 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans