cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Date Comparison Returns Incorrect Result

I read a lot of topics regarding comparing dates in Power Automate. My flow runs without an error but the result is not accurate, basically it returns every record. I suspect it has something to do with the date formatting, but the output date has the same formatting as the expression, so I am a bit confused. The only difference is in the visual representation of the column in SPO. Recreating the column from scratch is not an options because I have a lot of records.

Screenshot 2021-12-13 154830.pngScreenshot 2021-12-13 154852.pngScreenshot 2021-12-13 154924.png

1 ACCEPTED SOLUTION

Accepted Solutions
jdoss
Resolver III
Resolver III

Your function 'utcNow("yyyy-MM-dd")' is in single quotes. Which makes it a string. Remove them to get

@lessOrEquals(item()?['PublishDate'], utcNow('yyyy-MM-dd'))

View solution in original post

3 REPLIES 3
jdoss
Resolver III
Resolver III

Your function 'utcNow("yyyy-MM-dd")' is in single quotes. Which makes it a string. Remove them to get

@lessOrEquals(item()?['PublishDate'], utcNow('yyyy-MM-dd'))
Anonymous
Not applicable

Thanks. Can you briefly explain or provide a link what is the difference between using single and double quotes when comparing a date? I thought that I had to provide a string for comparison? 

jdoss
Resolver III
Resolver III

By putting it in single quotes you were creating a string with the content that is inside of the quotes

  • 'utcNow("yyyy-MM-dd")' = the actual string utcNow("yyyy-MM-dd")
  • utcNow('yyyy-MM-dd') = a string that is the current time in utc with the format yyyy-MM-dd, i.e. a date

You were trying to use an expression but by putting anything inside single quotes in Power Automate it is a string. The function is not sent as a string, but the argument (what's inside the parentheses) is a string.

Hope that helps.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,111)