Compare 2 Dates in Power Automate?

Options

I am building a custom tile on the constituent record that gives a 3-year summary of a donor's giving to our annual fund. So far so good, but if a donor didn't exist in FY24, I want to say “Record did not exist” instead of “No Giving”. I tried to do this by using a Condition action to see if the Date Added from RE was greater than 6/30/24. I used formatdatetime() to get both dates in the same format, but it just doesn't seem to be working. Is there another way to compare dates?

cf7bab435295f5e87e597ac2dce15736-huge-sc

Comments

  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary 1,500 Likes 2500 Comments Name Dropper

    @Ryan Carr
    You don't need to “formatDateTime()" on the date to do compare, actually, it is not good to do that.

    In general, what you want to make sure is you are comparing apple to apple. In terms of date/time, meaning, you need to be comparing in the same time zone.

    once you make sure you have the same timezone, the date/time string itself is directly “comparable”. YYYY-MM-DDTHH:MM:SS.mmmm

    so

    2024-01-01T13:11:00Z is less than 2024-01-01T13:11:15Z using just regular string compare.

  • @Alex Wong I was pulling the “Date Added” field, which was coming over as ‘8/28/2024’, so instead of formatdatetime() I used parsedatetime(), that got both dates into the format you are showing here, and that worked. Thanks!

Categories