cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
efialtes
Kudo Kingpin
Kudo Kingpin

Conditions: How to evaluate if a date has expired

Hi all

I am working with an Excel Table stored in Google Drive and GetRows action. The Excel table structure includes several registers, one of the columns is a Date.

 

My problem is I cannot find the way to avaluate if such date has expired (i.e. less than today). I added a Contition, and read carefully the Workflow definition Language (https://msdn.microsoft.com/en-us/library/azure/mt643789.aspx), section "Date functions". I found a function that provides current date & time, but could not find any Date comparison function. Any suggestions?

 

THank you in advance!

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Coen
Advocate III
Advocate III

Use a combination of the logical functions found on the same page. 

 

 

Less

Returns true if the first argument is less than the second. Note, values can only be of type integer, float or string.

 

Not sure if your date field will be interpreted as any of the allowed formats though. 

View solution in original post

This should be achievable if you create a condition and flip it to advanced mode. In the advanced mode, you can use the same expression syntax that Logic Apps uses. Expression reference is here: https://msdn.microsoft.com/en-us/library/mt643789.aspx

 

From there, it depends on the exact date format stored in Excel. If it's the usual ISO format (or similar), it will start like 2016-05-13 (i.e. year-month-day). If you just need an exact date match, other formats could work, but if you want to detect "earlier than" it will need to be a string sortable format (i.e. year before month before day).

 

So, start by using the editor to do a basic comparison with the timestamp field, then switch to the advanced view. This will tell you how to reference the field you care about in the expression. I my example I chose to use a 'Created' time from the flow trigger when testing this.

 

Then, to do the actual comparison, we can trim just the date part from the timestamp, and compare it against a custom-formatted utcnow expression. So putting this into the advanced condition did the trick for me to test if the date was today: @equals(substring(triggerBody()['Created'], 0, 10),utcnow('yyyy-MM-dd')) 

 

If you need to check for previous dates instead, this should work: @less(substring(triggerBody()['Created'], 0, 10),utcnow('yyyy-MM-dd'))

View solution in original post

2 REPLIES 2
Coen
Advocate III
Advocate III

Use a combination of the logical functions found on the same page. 

 

 

Less

Returns true if the first argument is less than the second. Note, values can only be of type integer, float or string.

 

Not sure if your date field will be interpreted as any of the allowed formats though. 

View solution in original post

This should be achievable if you create a condition and flip it to advanced mode. In the advanced mode, you can use the same expression syntax that Logic Apps uses. Expression reference is here: https://msdn.microsoft.com/en-us/library/mt643789.aspx

 

From there, it depends on the exact date format stored in Excel. If it's the usual ISO format (or similar), it will start like 2016-05-13 (i.e. year-month-day). If you just need an exact date match, other formats could work, but if you want to detect "earlier than" it will need to be a string sortable format (i.e. year before month before day).

 

So, start by using the editor to do a basic comparison with the timestamp field, then switch to the advanced view. This will tell you how to reference the field you care about in the expression. I my example I chose to use a 'Created' time from the flow trigger when testing this.

 

Then, to do the actual comparison, we can trim just the date part from the timestamp, and compare it against a custom-formatted utcnow expression. So putting this into the advanced condition did the trick for me to test if the date was today: @equals(substring(triggerBody()['Created'], 0, 10),utcnow('yyyy-MM-dd')) 

 

If you need to check for previous dates instead, this should work: @less(substring(triggerBody()['Created'], 0, 10),utcnow('yyyy-MM-dd'))

View solution in original post

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Users online (2,031)