In this video tutorial, Jonathon Silva from Pragmatic Works walks viewers through how to use the formatDateTime expression in Power Automate, comparing the capabilities of the new Co-Pilot Designer versus the Classic Designer.
Power Automate users often need to reformat date values retrieved from sources like SharePoint. The formatDateTime() expression allows formatting those dates into various human-readable or system-preferred styles.
Jonathon begins by showing a SharePoint-based trigger where an item’s creation captures two date values:
These dates are usually in the yyyy-MM-dd format, which is ideal for sorting but not always user-friendly. The goal is to convert them into formats such as Thursday November 9, 2023 or 09/11/2023.
In the Co-Pilot Designer, Jonathon demonstrates how to manually write expressions to format the date:
formatDateTime(triggerOutputs()?['body/DateOfRequest'], 'dddd MMMM d yyyy')
This structure includes:
'dddd' – Full name of the day (e.g., Thursday)'MMMM' – Full name of the month'd' – Day of the month'yyyy' – Full year
Other common format tokens include:
d or dd – Day (with or without leading zero)MM or MMM – Month number or abbreviated nameHH, mm, ss – Hour, minute, second
Jonathon also notes that users can pass an optional third parameter to set the language, such as 'en-US' or 'fr-FR', to localize the output.
While the new designer requires manual expression entry, the Classic Designer offers a more visual approach using "Format Data by Example." Here’s how:
12-Dec-2023 or December 12, 2023).This method auto-generates the appropriate formatDateTime() expression, reducing the need to remember date/time formatting tokens.
formatDateTime() expression is essential for customizing date output in Power Automate.Jonathon encourages users to try both methods—manual formatting in the Co-Pilot Designer and sample-based formatting in the Classic Designer—to determine what fits best for their workflows. Whether you're comfortable with expressions or prefer a guided interface, Power Automate offers flexible ways to format date and time fields effectively.
Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Power Automate and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.