Generate a date in your Flow
Recently quite a few citizen developer asked me how to format dates in a flow in Power Automate.
Quite often people want to send dates in an email, however formatting these dates doesn’t seem to be that easy. In this post I will look at formatDateTime to format dates in Power Automate.
An example without formatting the date
In my example I’m just going to take the current date and send it out by email:
This now gives me the following email:
OK, that is ugly!
To get a proper date you might be happy with the first part. Or maybe you want to include the time as well but I still have to find the first person who would be happy with that T and Z in the date and time.
formatDateTime flow function in Power Automate
Now I add Flow’s formatDateTime function and a format string ‘dd-MM-yyyy’.
Using this format and I will see that my date will appear in the European format of day-month-year.
For the full overview of the format strings please have a look at the formatDateTime function documentation
Other uses for the formatDataTime flow function
You can use the formatDateTime flow function to format dates and that is the most common use.
When you want to get for example just the day of the month or if you just want to get the hour of the time you could use the formatDateTime flow function as well.