cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Date Format

result.JPG
My SQL Query results pulls in a date. I need to take this date, add 365 days to it, and compare that date to utcNow. I do not know how to format the date to look like utcNow in order to compare

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

@victory1234 

Hi there!  You can do all this with an expression, but I don't know how, so here's my version Man Happy:   Look for this action "Add to Time" to add the 365 days to the date.20190719b.PNG

From there, you can use the Convert Time Zone function to format the date however you'd like (the from and to timezones can both be UTCz).

 

Keep us posted.

-Ed-

 

 

If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

View solution in original post

4 REPLIES 4
Highlighted
Super User II
Super User II

@victory1234 

Hi there!  You can do all this with an expression, but I don't know how, so here's my version Man Happy:   Look for this action "Add to Time" to add the 365 days to the date.20190719b.PNG

From there, you can use the Convert Time Zone function to format the date however you'd like (the from and to timezones can both be UTCz).

 

Keep us posted.

-Ed-

 

 

If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

View solution in original post

Highlighted

I'm new to Flow and I did not know Add to time was an option so thanks for that @edgonzales . The problem that I am getting is with the date itself. My problem is I do not know how to take the sql output and convert it to just the date and making that date 8601 format

 

Error.JPG

Highlighted

Ah, ok.  So, if you do the Convert Time zone first, then you can format it before the add time step.  OR, you can use this expression in the add-time step (the stuff in red you would replace with the dynamic output from your SQL (let me know if you need help there)):

 

formatDateTime(body('Get_user_profile_(V2)')?['hireDate'],'yyyy-MM-ddTHH:mm:ssZ')
 
Or, (even better) add the days and format the thing all at once (this was new to me):
 
addDays(body('Get_user_profile_(V2)')?['hireDate'],365,'yyyy-MM-ddTHH:mm:ssZ')
 
When it comes to comparing the dates, I did this blog a while back that talks about the weirdness that is date math in Flow.
Give that a go and let us know what happens.
Highlighted
Dual Super User III
Dual Super User III

Hi @victory1234 

 

Please see the screenshot below: 

js.PNG

Here, I have directly put the original date in the variable as a hardcoded value, you can reference it to the output from the previous actions. 

Expression used to format the date and add days: 

addDays(formatDateTime(variables('ss'),'yyyy-MM-ddThh:mm:ss'),365)

And then compare with utcnow()

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (16,144)