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

comparing dates is not working

(0) ShareShare
ReportReport
Posted on by 1,552

Hi,

Today's date is 26/10/2020 and dateTime1 is 26/10/2020

so when i say if (26/10/2020 > 26/10/2020 2 days) then it should not enter the if statement but it does in my case so how come?

if(DateTimeUtil::getSystemDateTime() > DateTimeUtil::addDays(dateTime1 ,2)
{
            info(strFmt("%1",DateTimeUtil::addDays(dateTime1,2)));
            info(strFmt("%1",DateTimeUtil::getSystemDateTime()));
}

I have the same question (0)
  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Junior AX,

    What output do you see in the infolog?

  • junior AX Profile Picture
    1,552 on at

    Hi Sergie,

    pastedimage1603695830683v1.png

    could it be that it add days after comparing. I'm not sure why this is happening?

  • Blue Wang Profile Picture
    on at

    Hi Junior Ax,

    Based on your code,  it does not enter the if statement.

    136.PNG

  • junior AX Profile Picture
    1,552 on at

    Hi Blue Wang,

    Try defining dateTime1 alone and add the 2 days in the compare. Does it enter it?

  • Blue Wang Profile Picture
    on at

    Hi Junior,

    137.PNG

  • junior AX Profile Picture
    1,552 on at

    Hi BlueWang,

    while select table1
    where DateTimeUtil::getSystemDateTime() > DateTimeUtil::addDays(table1.DateTime ,2)
    {
    info(strFmt("%1",table1.DateTime));
    info(strFmt("%1",DateTimeUtil::addDays(table1.DateTime ,2)));
    info(strFmt("%1",DateTimeUtil::getSystemDateTime()));

    }

    pastedimage1603698050447v1.png

    i thought it's because the table field is allow edit and allow edit on create = false, i changed it to true but still

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi junior AX,

    What is the EDT assigned to the DateTime field in the table?

  • junior AX Profile Picture
    1,552 on at

    Hi Gunjan,

    no EDT, it's just utcDateTime field

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi juniorAX,

    Could you please use the DateTimeUtil::applyTimeZoneOffset() to DateTime1 and use the UTC timezone. Please share the result from running the query.

  • junior AX Profile Picture
    1,552 on at

    Hi Gunjan,

    can you please explain more, what does this function mean and how to use it to get my result?

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 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans