This tutorial explains how to add days to the date while working with Power Automate date and time manipulations and covers a few examples related to the adddays() in Power Automate.
Here, we will discuss the examples like:
- adddays function in power automate
- Add 1 day to date in Power Automate
- Power Automate utcnow add days
- Add 15 days from today in Power Automate
- Power Automate add days negative
- Power Automate add days to date format
- Power Automate Created plus 7 days
- Power Automate add days to Sharepoint Date
- Add year to date in Power Automate
- Add working days to the date using Power Automare
Power Automate adddays() Function
Power Automate Date and time functions have similar functions that resemble adddays() functions like addHours(), addMinutes(), and addSeconds(). Power Automate adddays() expression is useful for adding a specific number of days to the date or timestamp.
This function can add a positive or negative number of days, where positive numbers will add the number of days, and negative numbers will subtract the number of days.
The result will return the provided date + number of days in a particular format.
Syntax: addDays('timestamp', days, 'format')
This is a simple explanation of the Power Automate adddays() function.
Add 1 Day to Date using Power Automate
Now, let’s check how to add days to a particular date using a Power Automate flow.
Example:
Let’s consider a particular timestamp, ‘19-05-2024‘. I wanted to add one day to this date so that the result will return ‘20-05-2024‘.
Steps:
1. Navigate to https://make.powerautomate.com to open the Power Automate Home page -> Click +Create -> Select ‘Instant cloud flow’ -> In the next window, Provide a flow name & select trigger ‘Manullay trigger a flow’ -> Tap Create button -> Inside the trigger, add a date input.
2. Select the ‘Initialize variable‘ flow action to select the trigger date. Provide a name for a variable, and select the data type and value.
3. Take a Compose action to give the expression to add days to the triggered date.
Insert the below-placed code in the expression:
addDays(variables('Date'),1,'dd/MM/yyyy')
4. After that, you can save and run the flow manually. In the run flow window, pick a date to which you want to add days -> Click Runflow.
Output:
Now, you can check that the output of the compose action will return a timestamp by adding one day to the triggered date, as shown below:
This is how to add a day to the date using the adddays() expression in Power Automate.
Power Automate utcnow() Add Days
To add days to the current date using Power Automate, check out the below example:
Example:
Let us assume the current date is 20-05-2024. My requirement is to add 30 days to the utcnow(), which would result in 20-06-2024.
Follow the same steps mentioned in the above example:
1. In the Initialize variable action, take the utcnow() function that will get the current date and time.
2. Add the below-given expression in Compose action, which will add days to the current date.
addDays(variables('Date'),30,'yyyy MMMM dd')
Note:
If you want to get 15 days from today, use the expression like addDays(utcNow(),15,’yyyy/MMMM/ dd’).
Output:
The flow will give the following result in compose outputs. Refer to the image below:
This way, you can add days to the utcnow() function in Power Automate.
Power Automate Adddays Negative
To know about adding negative days to the timestamp, look at the example below:
Example:
Suppose I take the date variable value ‘01-05-2024‘ and want to add 7 negative days to it. The Power Automate adddays() function will subtract the number of days from the given date and display the resulting date [24 -04-2024].
Steps to do this:
1. Inside the Initialize variable, take the value of the triggered date.
2. In the Compose data operation, insert the expression that will add negative days to the date.
addDays(variables('Date'),-7,'MMMM dd, yyyy')
3. Save and run the flow manually. In the Runflow window, pick a date that you want to trigger and click on the Runflow button.
3. You can now check the output, it will show the result as subtracting days from the date.
- The output will be April 24, 2024.
This is about adding negative days to the date using the Power Automate adddays() expression.
Power Automate Add Days to Date Format
In Power Automate, as you all know, we can also format the date in a customized way by using Power Automate to add the days() function other than adding days.
Example:
Let’s take a specific date, ‘2024-05-01′. Now, my requirement is to add two days to this particular date and retrieve the result in a specific format, like Weekday, dd/MM/yyyy [Monday, 01/05/2024].
Now, let’s see how to add days to the date format:
1. In the Compose action, give the expression to add days and change the custom format.
addDays(variables('Date'),2,'dddd, dd/MM/yyyy')
2. The image below represents the triggered date with the default format.
Output:
When the flow runs successfully, you can see that the days have been added to the date and displaying in a required format.
The table below represents some of the date formats that you can use in Power Automate:
Format | Description | Output |
yyyy | year | 2024 |
MMMM | Month name | October |
dd | day | 11 |
yyyy-MM-dd | Year-Month-Day | 2024-10-12 |
yyyy-MM-ddTHH:mm:ssZ | Date and Time | 2024-10-12T14:30:00Z |
dddd, dd/MM/yyyy | Weekday,date/Month/Year | Monday, 01/05/2024 |
MM-dd-yyyy | Month-date-year | 05-20-2024 |
MMM dd,yyyy | Month Day, Year | Jan 16, 2024 |
This is about Power Automate add days to the date format using the adddays() function.
Power Automate Created Plus 15 Days
Here, let me show another example of Power Automate add days to date.
Example:
I have a SharePoint list named ‘Upcoming Sales Meeting‘ with a few columns, as looked at in the below image:
My requirement is to delete the SharePoint list of items that are older than 15 days.
Check out the steps below:
1. Log in to Power Automate, click on Create, select Scheduled cloud flow, and then click on the Create button.
Provide the parameters below:
- Interval: Enter interval as 1.
- Frequency: Choose the frequency as Day from the drop-down.
- Time zone: Select the Timezone the flow should run.
- At these Hours: Choose the Hours when the flow should run.
2. Now, take the Get items flow action to retrieve all the SharePoint list items. Select the Site Address and List Name.
In the Filter Query parameter, provide the expression that will retrieve the list items where a created date is less than or equal to 15 days.
Created le '@{addDays(utcNow(),-15,'MM/dd/yyyy')}'
3. After that, add a Delete item flow action with details like the Site Address and List Name.
- Id: Select ID of Get items from dynamic content.
Then, For each loop will be added by taking the body/ value of the Get items.
4. Now, save and run the flow manually. You can see that the SharePoint list items have been deleted based on the provided expression.
This is how to use the adddays() expression in Power Automate to add particular days to the default SharePoint columns.
Power Automate Add days to SharePoint Date
When using a SharePoint list, the date and time values need to be manipulated. Now, let us add a year to the date in a Power Automate flow.
Example:
To explain this example, I will use one of my SharePoint lists, ‘Project Details,’ with a few columns like:
Here, I wanted to show how to add a year to the date using the adddays() function in Power Automate.
- Project start date + Project Duration in days => Update Project End date
So, to add a year to the date using the adddays() function, I will take the Project duration days as 365 days.
Follow the below steps:
1. Create a Power Automate automated cloud flow -> Select When an item is created or modified trigger -> Choose Site Address and List Name.
2. Take Compose flow action and give the below expression. Insert the below-given expression:
addDays(triggerBody()?['StartDate'],int(triggerBody()?['ProjectDurationDays']),'MM/dd/yyyy')
3. Now, choose and select the Update item action. Provide the Site Address, List Name, and Id values from dynamic content.
- Project End Date: Select outputs of compose action from dynamic content.
4. Then, save and run the flow. Now, add or modify an item in the SharePoint list.
5. When the flow triggers and runs successfully, you can see that the Project End Date has been updated in the SharePoint list.
This way, you can add a year to the SharePoint date column with the Power Automate adddays() function.
Power Automate Add Working Days to Date
To know about how to add working days to the date, check out this example:
Example:
I have a Microsoft Form named ‘Product Order Details‘ with a few details as shown in below image:
My requirement is to send an email to the responder about the Product Delivery Date that needs to be delivered only on business days [Working days].
Steps to follow:
1. In the Power Automate, select Automated cloud flow -> Choose When a new response is submitted trigger -> Pick Form Id from the drop-down.
2. To retrieve the submitted details from the Microsoft form, Select Get response details. Provide Form Id and Response Id from dynamic content.
3. After that, add a Compose flow action to take the Product Ordered date value from dynamic content in the Inputs section.
4. Add one more Compose action and select Delivery Estimation days value from the dynamic content.
5. Next, add a Select flow action to range the number of days of the year [0-365] and the day of the week for the particular date.
Map the following expressions with values:
Key | Value |
Date | formatDateTime(addDays(outputs(‘Date’),item()),’yyyy-MM-dd’) |
Day | dayOfWeek(addDays(outputs(‘Date’),item())) |
The select output will display a range of 365 dates, something like this:
6. After that, add the Filter array action to filter only the weekdays from the above step.
- From: Take Outputs of select action from dynamic content.
- Filter Query: Paste the below-given query in advanced mode.
and(not(equals(item()['day'], 0)), not(equals(item()['day'], 6)))
7. Next to this, choose and select Compose action to provide the expression that will only get the resulting date by adding days to the Product ordered date.
Expression: body('Filter_array')[outputs('Days')]['date']
8. To send the details regarding the Product delivery date, add Send an email(V2) flow action and Set the parameters like
- To: Take the responder’s email from the dynamic content.
- Subject: Add a subject line for the email
- Body: Provide a description of the email along with outputs of compose that has a resulting date.
Save the flow.
9. Whenever a user submits the form, an email about the product delivery date will be sent to the responder’s Outlook, as you can see from the screenshot below.
This is how to add working days to the date using Power Automate.
Conclusion
I hope you got an idea of adddays() in Power Automate. I have explained how to add days to a date in Power Automate with various real examples.
You may also like the following tutorials:
- Power Automate Concatenate Strings
- Power Automate Trigger Conditions
- When a New Email Arrives Subject Filter in Power Automate
- Power Automate Convert String to Float
- Power Automate Increment Variable
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com
Thanks for the great tutorial. I tried to capture a date value from a SharePoint list, add 7 days to it and write the result back to a new item in the list. So I did exactly as you described it.
PA doesn’t let me create the new item, though. It tells me it expects a “String/date” value which the composed value apparently doesn’t have. Any ideas?
why use compose instead of setting the fields right with the expressions? is compose a need?
Hi There.
I’m trying to follow your steps for [Power Automate add days to date]
But I keep getting a failure with this error. [
InvalidTemplate. Unable to process template language expressions in action ‘Compose’ inputs at line ‘0’ and column ‘0’: ‘The template language function ‘addDays’ expects its first parameter to be a string that contains the time. The provided value is of type ‘Null’. Please see https://aka.ms/logicexpressions#adddays for usage details.’.]
What am I doing wrong?