cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
victory1234
Level: Powered On

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
Super User
Super User

Re: Date Format

@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
Super User
Super User

Re: Date Format

@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

victory1234
Level: Powered On

Re: Date Format

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

Super User
Super User

Re: Date Format

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.
Dual Super User
Dual Super User

Re: Date Format

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
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,540)