cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Roberto_el_Hajj
Advocate II
Advocate II

Add X months or year to today's date

Hello,

Please advise me the best practice,

 

I have a variable containing a number and another containing unit ( day, months, year).

In the first variable, I input for example 4, and in the second I input the unit ( day or months or year). I want to add 4 months to the current date.

 

Any help would be highly appreciated, thank you in advance.

2 ACCEPTED SOLUTIONS

Accepted Solutions
ekarim2020
Community Champion
Community Champion

Power Automate has a number of Date and time functions.

See: https://docs.microsoft.com/en-gb/azure/logic-apps/workflow-definition-language-functions-reference#d...

2021-12-03_08-41-41.png

If you dont want to use expressions, you could try the following which will add 4 months to the current date, then convert it to a local time zone if needed:

2021-12-03_08-50-48.png

Sample runtime with the final date output (from the Convert time zone action) in MM/dd/yyyy format:

2021-12-03_08-53-31.png

 

Hope this helps.


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

View solution in original post

ekarim2020
Community Champion
Community Champion

Here is a basic flow:

2021-12-03_09-55-20.png

There are the expressions used:

(1) convertFromUtc(utcNow(),'AUS Eastern Standard Time')

(2) addToTime(outputs('Compose_Local_Time'),4, 'Month')

(3) formatDateTime(outputs('Compose_Add_to_Time'),'MM/dd/yyyy')

 

You can merge the steps, change the time zone, and Date format as needed.

 

Here is a sample runtime output:

2021-12-03_09-59-22.png

 


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

View solution in original post

4 REPLIES 4
ekarim2020
Community Champion
Community Champion

Power Automate has a number of Date and time functions.

See: https://docs.microsoft.com/en-gb/azure/logic-apps/workflow-definition-language-functions-reference#d...

2021-12-03_08-41-41.png

If you dont want to use expressions, you could try the following which will add 4 months to the current date, then convert it to a local time zone if needed:

2021-12-03_08-50-48.png

Sample runtime with the final date output (from the Convert time zone action) in MM/dd/yyyy format:

2021-12-03_08-53-31.png

 

Hope this helps.


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

Roberto_el_Hajj
Advocate II
Advocate II

Thank you @ekarim2020  for providing me with this solution.

I would really appreciate it if you could provide me with the same solution but as an expression please?

ekarim2020
Community Champion
Community Champion

Here is a basic flow:

2021-12-03_09-55-20.png

There are the expressions used:

(1) convertFromUtc(utcNow(),'AUS Eastern Standard Time')

(2) addToTime(outputs('Compose_Local_Time'),4, 'Month')

(3) formatDateTime(outputs('Compose_Add_to_Time'),'MM/dd/yyyy')

 

You can merge the steps, change the time zone, and Date format as needed.

 

Here is a sample runtime output:

2021-12-03_09-59-22.png

 


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

Roberto_el_Hajj
Advocate II
Advocate II

Thank you so much @ekarim2020 for your solution I really appreciate it.

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!

Top Solution Authors
Top Kudoed Authors
Users online (1,270)