Do you need to format the dates in your flow?
Date values are a big part of most datasets. This means you’re likely going to work with them in any workflows.
When working with dates in a flow, you might need to change the format of the date to suit the needs of your audience. For example, you might want to change the format from mm/dd/yyyy to dd/mm/yyyy.
You can change the date format to match just about any pattern!
This post will show you how to change the date format in Power Automate.
Format a Date with the formatDateTime Function
Formatting dates is an important and common task in Power Automate. This is why Power Automate has a dedicated workflow function for formatting dates.
formatDateTime(timestamp, format, locale)
The formatDateTime function will take a date value and format it based on a custom format pattern.
timestampis the date or datetime you want to format.
formatis the pattern you want your date format to match. You can use a standard format or custom format string.
localis the local or region to use for output.
en-usis the default.
In this example, the date inside a compose action is formatted using a
When this runs it will result in the date 21/08/2022.
Many other custom date formats are possible. Here is a list of date format codes and their output based on the example date 2022-08-09.
|Single digit day
|Double digit day
|Short day name
|Long day name
|Single digit month
|Double digit month
|Short month name
|Long month name
|Single digit year
|Double digit year
formatDateTime('2022-08-09', 'dddd, MMMM d, yyyy', 'en-US')
These can be combined in just about any way. For example, this format
dddd, MMMM d, yyyy will result in a date like Tuesday, August 9, 2022 for the date 2022-08-09.
Format a Date with the Convert Time Zone Action
Unfortunately, there is no user-friendly action available for the formatDateTime function.
But there still is an action available that can be used to format your dates.
You can use the Convert time zone action since this gives you an extra option to format the output. You just need to convert from and to the same timezone. This will essentially only use the format part of the action.
This way, you get a user-friendly dropdown option to choose your desired date format and don’t need to mess around with the expressions.
- Add the Convert time zone action to your flow.
- Enter the date or dynamic content referencing the date into the Base time input field.
- Select your desired format from the Format string dropdown menu. You can also choose the Enter custom value option and then enter your own custom format code.
- Select the same option in both the Source time zone and Destination time zone dropdown menu. For example, you can select UTC Coordinated Universal Time options in both.
When you run this action, it will return the desired format. In this example, you can see the date 2022-08-21 is formatted as Sunday, August 21, 2022.
Format a Date using Format Data by Example
This is a great new option to help you build your own expressions if you’re not comfortable working with the workflow functions.
It will allow you to enter a few examples of the output you desire and then build an expression that will return those results.
- Click on any field in Power Automate where you want to return the formatted date.
- Go to the Expression tab of the popup.
- Select the Format data by examples option.
This will open a side pane on the right and you will be able to choose the date you want to format.
- Select the date dynamic content to format. This example is formatting a date from a compose action.
Now you will need to provide at least one example transformation.
- Add an Example value for Outputs. This is a sample of what values might be in your dynamic content. Here the date 2022-08-01 is entered.
- Enter the Desired output based on the Example value for Output. When you start typing, it will provide you will Suggested transformations that you can select.
- Click on the Get expression button.
formatDateTime(parseDateTime(outputs('Date')), 'MMMM d, yyyy', 'en-US')
This will create a Suggested expression for you which you can copy into your clipboard and use in any field of your flow.
You can also test out the new formula on a few other Test value inputs using the Test button. This will help give you confidence that the suggested expression is correct and will provide the results you want!
- Click on the Apply button.
This will add the suggested expression to the action from step 1.
Formatting dates is a common task. Different audiences may require different date formats.
It’s possible to format your dates in Power Automate without too much trouble.
Power Automate offers a dedicated formatDateTime function for this purpose, but for a more user-friendly method to format dates, you can also use the Convert time zone action.
Also, you can check out the Data by example feature to help you build an expression if you’re not comfortable with the workflow functions.
How do you format dates in Power Automate? Do you have any other tips? Let me know in the comments below!