cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tludwig
Advocate I
Advocate I

Comparing date-times with a condition

I'd like to create a condition within a Do Until loop that will switch to the "Yes" condition when a date-time value that I created with the "Add to Time" action before the loop is before (or less than?) the current date-time which is refreshed within the Do Until loop each time it iterates.

 

I tried making the condition when the "Add to Time" dynamic value was less than the "Current Time" dynamic value but it never seemed to switch to the "Yes" condition.

 

From what I've read, I may need to use Advanced mode and type in some code or convert the date-times to ticks but I don't know how to do that. Any suggestions? Thanks!

 

flow1.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
v-litu-msft
Community Support
Community Support

Hi @tludwig,

 

If you want to compare the Date time in the condition, you should use formatDateTime() function to convert the date stamp sort by the size of the date-time unit, "yyyy-MM-ddThh:mm:ssZ"

 

For example:

formatDateTime(body('Current_time'),'yyyy-MM-ddThh:mm:ssZ')

Annotation 2020-05-06 134226.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-litu-msft
Community Support
Community Support

Hi @tludwig,

 

If you want to compare the Date time in the condition, you should use formatDateTime() function to convert the date stamp sort by the size of the date-time unit, "yyyy-MM-ddThh:mm:ssZ"

 

For example:

formatDateTime(body('Current_time'),'yyyy-MM-ddThh:mm:ssZ')

Annotation 2020-05-06 134226.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

on that:
Unable to process template language expressions for action 'Condition_2' at line '1' and column '2320': 'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Integer'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.

 

so i tried to case it using string():
Unable to process template language expressions for action 'Condition_2' at line '1' and column '2320': 'In function 'formatDateTime', the value provided for date time string '17' was not valid. The datetime string must match ISO 8601 format.'.

formatDateTime(body('Current_time'),'HH') >= formatDateTime(String(17),'HH') & formatDateTime(body('Current_time'),'HH') <= formatDateTime(String(07),'HH')formatDateTime(body('Current_time'),'HH') >= formatDateTime(String(17),'HH') & formatDateTime(body('Current_time'),'HH') <= formatDateTime(String(07),'HH')

looks like pva flows doesn't like HH only, worked when i did this:
formatDateTime(body('Current_time'),'HH:mm') >= formatDateTime(String(17:00),'HH:mm') & formatDateTime(body('Current_time'),'HH:mm') <= formatDateTime(String(07:00),'HH:mm')

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events happening this month - don't miss out!

 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (4,018)