Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Date time comparison is not working

(0) ShareShare
ReportReport
Posted on by 45

Hi All,

I have requirements to check if particular date time has been expired or in past. So I'm using control components in power automate but it seems it's not working for time. I realised it's working fine for dates but I also need to compare time. 

Output for below formula is

06/07/2022 06:16 PM

06/07/2022 12:15 AM

So obviously first date is greater than second one but anyhow power automate is not considering AM PM. And it evaluate outcome as false.

If I give both time in PM or AM it works fine.

Any idea how we can achieve it?

IMG_5F00_20220705_5F00_222539.jpg

  • Suggested answer
    AnantaYogi Profile Picture
    AnantaYogi 45 on at
    RE: Date time comparison is not working

    Thank you Qingqing Xin, it worked like a charm :)

  • Verified answer
    Qingqing Xin Profile Picture
    Qingqing Xin on at
    RE: Date time comparison is not working

    Hi AnantaYogi,

    You can change the time on a 12-hour clock to a time on a 24-hour clock and then compare it.

    The entire process is set up as follows:

    1.Enter the time you want to compare.

    1856.png

    2.Initialize variable

    7838.png

    Change the time on a 12-hour clock to a time on a 24-hour clock.

    formatDateTime(triggerBody()['text'],'yyyy-MM-ddTHH:mm:ss')

    formatDateTime(triggerBody()['text_1'],'yyyy-MM-ddTHH:mm:ss')

    85441.png

    3.Add ‘condition’ step. Compare the variables that you just changed.

    3175.png

    4.Save and test.

    330210.png

    5.The test result is as follows:

     It evaluate outcome as true.

    8156.png

    Regards,

    Qingqing Xin

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

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,187 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,966 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans