Solve Common Problems with Dates in Power Automate (Part 2)
Part 2 of 3
Intro
You’ve begun using Power Automate and then you see this “2024-06-20T00:00:00Z”. There’s nothing more frustrating! Dates in Power Automate can be one of the most confusing things to get right, but they shouldn’t be a reason you stop using the app. Throughout this 3-part series, we will solve the most common problems with dates in Power Automate.
Add Days Function
The Scenario
Our Team submits PTO requests through a Form that then goes through an approval process. Once approved, the PTO is then scheduled on our team Outlook calendar.
The Solution
Team members select a start and end date for their PTO in Forms, but you would run into some problems when creating the event if you simply put in the start date and end date dynamically from the form.
For this example I selected PTO in the Form from 4/1-4/3.
If you don’t make any changes, Power Automate will assume the time is at 00:00:00. For a start date, this works! The team member is on PTO starting at the beginning of that day.
However, for an end date, this will show up on the calendar as only going until the beginning of the last day of PTO. You want to show the calendar event throughout the full last day.
You can see in the calendar invite it shows my PTO only going through 4/3.
The solution here is to use the addDays formula for the end time in the calendar event action.
Here is the formula I used:
addDays(outputs('Get_PTO_Form_Response_Details')?['body/PTORequest'],1,'MM/dd/yy')
- The outputs section of the formula is a dynamic value.
- The 1 represents the amount of days being added.
- You can also choose to format the date a specific way in this formula or leave this part of the syntax out.
Now you have a calendar invite that ends of the correct day.
Summary
I hope you find this tip useful next time you’re building a Flow in Power Automate that uses dates!
If you’re not an existing Knack Training client and want to bring training like this to your company, you may be interested in our Power Automate training track! Download the informational one pager for the course track here and get in touch using the Contact Us form on the website.