Power Automate: previous and/or next date/time (hour, month, year, etc.)
There are 2 ways to get the previous and/or the next day, seconds, year, etc. Option 1 is to use “add to time” or “subtract from time”. For my article, I will use the first one (the second one works the same way):
Click on the “base time” field then click on the “fx” button:
To put this code (it will get the current date): utcNow()
Click on “add” then fill the following fields to get the previous month by putting “-1” in the “interval” field:
NOTE: using “subtract from time”, I have to put “1” instead of “-1”
I will add a new step “compose”:
Click on the “inputs” field to click on the “fx” button to put: formatDateTime(,'MMMM')
Click before the coma “,” then “dynamic content” to select this option:
![]() |
![]() |
Once done, click on “add”:
This step is necessary to format the date correctly, without it, I will get a date in an ISO format. For more format options, read Power Automate: date and time.
Option 2 is to use only “compose” with the function:
- addToTime()
- Or subtractFromTime()
so I will add another one. This time, I will put this code for the next year: addToTime(utcNow(),1,'year','yyyy')
NOTE: using “subtractFromTime”, I have to put “-1” instead of “1”
The next year is calculated based on the current date:
- Change the number “1” to get a different year, for instance, by putting “-1”, I will get the last year
- Change 'year','yyyy' by other types:
- For “second”: 'second','ss'
- For “minute”: 'minute','mm'
- For “hour”: 'hour','HH'
- For “day”: 'day','dd'
- For “month”: 'month','MMMM'
Now to have both (option 1 and option 2), I will combine both outputs into a step, for instance, in the “send an email” step into the “subject” and “body” fields:
- The “compose: outputs” corresponds to option 1
- The “compose 1: outputs” corresponds to option 2
Interesting Topics
-
Be successfully certified ITIL 4 Managing Professional
Study, study and study, I couldn’t be successfully certified without studying it, if you are interested...
-
Be successfully certified ITIL 4 Strategic Leader
With my ITIL 4 Managing Professional certification (ITIL MP) in the pocket, it was time to go for the...
-
Hide visual and change background color based on selection
Some small tricks to customize the background colour of a text box...
-
Stacked and clustered column chart or double stacked column chart
In excel, I use a lot the combination of clustered and stacked chart...
-
Refresh Power BI
From the Power BI Service, I can set refresh but, for instance, there is no option to do it monthly or each time a change is made...
-
Power BI alerts to be sent by email from an excel file based on condition
I will explain how to send a list of emails from an excel file after creating alerts...








