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, ...
Answered

Date function in AX 2012 R3

(0) ShareShare
ReportReport
Posted on by 535

Hi,

I want to convert Today's date into Yesterday date using X++.

For E.g : Today - 10/09/2019 to Yesterday - 10/08/2019.

Kindly suggest here.

Thanks and Regards,

Vignesh 

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,162 Moderator on at
    Date dateToday = systemDateGet();
    Date dateYesterday = dateToday - 1;
  • Verified answer
    Mohamed Ahmed Hassan Profile Picture
    169 on at

    static void Job23(Args _args)

    {

      TransDate transDate = today();

      ;

      transDate++;

      print transDate - 2;

      pause;

    }

  • Verified answer
    Blue Wang Profile Picture
    on at

    Hi Vignesh,

    Besides that, you can use addDays(date,-1);

    utcDateTime         todayLessOneDay,
                            // Get the actual UTCDateTime based on the current system
    todaysDateTime = DateTimeUtil::utcNow();
                            
    // Convert it to a string, just to show in on the info log
    info(DateTimeUtil::toStr(todaysDateTime));
       
    // Now less a day
    todayLessOneDay = DateTimeUtil::addDays(todaysDateTime, -1);
       
    // And Info it out again
    info(DateTimeUtil::toStr(todayLessOneDay));

    1070.PNG

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
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans