cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

gt and lt in utnow work, but not eq...probably a formatdate issue?

Hi- I am brand new to flow/automate and have had great success building flows with gt and lt TODAY.

I cannot get eq TODAY to work however. I assume it's because of a date formatting issue because it is probably returning minutes in addition to day and therefore there is no EXACT match?

 

If so, how do I write the query to also format the returned date to only include day?

 

Here is my current query:

Created eq 'addDays(utcNow(),-9)'

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: gt and lt in utnow work, but not eq...probably a formatdate issue?

@ahowes OK let's look at this another way. First of all add the Get items action but don't add a filter query. Then add a Convert time zone action with the base time as the Created column from your library and the format string as yyyy-MM-dd which Power Automate likes for comparisons.
Next add a Compose and add the expression formatDateTime(addDays(utcNow(),-13),'yyyy-MM-dd') 

(mine was look at documents creating 13 days ago just for this test).

Finally, add a condition that looks at if the converted time zone is equal to the output of the Compose  x Days Ago then do whatever actions you need to do.

0getItems-Convert-Compose.png

 

1-Condition.png

As you can see from the flow result below, the outputs of the convert time zone and compose are the same:

2-outputs.png

So hopefully that will give you another method to get your flow working.

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

View solution in original post

4 REPLIES 4
Highlighted
Super User III
Super User III

Re: gt and lt in utnow work, but not eq...probably a formatdate issue?

@ahowes 

The addDays() expression allows you to supply a date format - add a comma after the -9 and add your date format inside of single quotes.

Here is a link to the date format documentation

Please note that, if your data is stored in SharePoint, that a full date time minute second string is stored - trying to match that won't work for you.

What are you trying to do?

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Highlighted
Helper I
Helper I

Re: gt and lt in utnow work, but not eq...probably a formatdate issue?

Thanks, Scott.

That did not return the expected result 😞

I have multiple records created 10 days ago, but the query Created eq 'addDays(utcNow(),-10,'d')' returned no results (the gt and lt work, just not the eq). 

 
Yes, the records are in a SharePoint list and I'm using the default Created column. I assume I need to strip the hours/minutes from the date returned...
 
Thanks again!
Highlighted
Super User III
Super User III

Re: gt and lt in utnow work, but not eq...probably a formatdate issue?

@ahowes OK let's look at this another way. First of all add the Get items action but don't add a filter query. Then add a Convert time zone action with the base time as the Created column from your library and the format string as yyyy-MM-dd which Power Automate likes for comparisons.
Next add a Compose and add the expression formatDateTime(addDays(utcNow(),-13),'yyyy-MM-dd') 

(mine was look at documents creating 13 days ago just for this test).

Finally, add a condition that looks at if the converted time zone is equal to the output of the Compose  x Days Ago then do whatever actions you need to do.

0getItems-Convert-Compose.png

 

1-Condition.png

As you can see from the flow result below, the outputs of the convert time zone and compose are the same:

2-outputs.png

So hopefully that will give you another method to get your flow working.

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

View solution in original post

Highlighted
Helper I
Helper I

Re: gt and lt in utnow work, but not eq...probably a formatdate issue?

Rob-

Thanks, worked like a charm! But...sure seems like a lot of steps to do something that ought to be so much easier. I'm brand new to Power Automate, so I have a lot to learn. I'll go back and study your reply and all those steps in the app so I can fully understand them.

Have a great week!

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (8,247)