I wrote a few days ago on how to format the day of the week and thought it would be a good idea to show you how to do the same for months, or years, not only in the format you want but also in the language you want. It’s incredibly complex to format a date in other languages, but since Power Automate has built-in features for this, we can take advantage of them.
Thanks to Johannes in the comments, who pointed out that there would be a better solution, and that reminded me of an article I wrote a few years ago about the formatDateTime function. So today, let’s explore it and see what kinds of dates we can get.
The day of the week.
First, let’s show you how to do the day of the week. For example, today (day of the article):
formatDateTime(utcNow(),’dddd’,’pt-PT’)
We’ll get:
“Terça-feira” is “Tuesday” in Portuguese. So how did we get this? Notice that the “formatDateTime” function has three parameters. The first is the date we want to process, the second is the date format, and the last is the locale to which we wish the date translated. So if we include “pt-PT’, then we would have the Portuguese site. We’ll look at the middle parameter in a second.
If you want to customize the day of the week with something else, or any other change, you can use this article that details how to generate it yourself.
Some examples
Let’s look at the most common date formats and how to get them. For example, let’s format today’s date in the full and short format in the United States locale:
formatDateTime(utcNow(),'MMMM dd, yyyy','en-US')
We’ll get:
The short format:
formatDateTime(utcNow(),'MM/dd/yy','en-US')
We’ll get:
I understand that these formats may look strange to other countries. Still, it’s more important to have things make sense to the people looking at the data, hence the importance of showing the dates in a format that makes more sense in the country, even if they speak the same language. For example, if we look at England (BBC, for example), here’s how they represent the date:
formatDateTime(utcNow(),'dd MMMM yyyy ','en-Gb')
Here’s what we’ll get:
Finally, let’s look at Germany, for example. A nonspeaking country that uses a different notation for dates:
formatDateTime(utcNow(),'dd.mm.yyyy ','de-DE')
Here’s what we’ll get:
Let’s include the day of the week for good measure:
formatDateTime(utcNow(),'dddd','de-DE')
We’ll get:
Where to get the parameters?
Both the second (the format) and the last (the locale) are standards in the market.
For the format, you can get it in Microsoft’s official documentation and mix and match them as you see fit.
For the locale, here’s a list that you can use.
Final thoughts
There are millions of combinations and different representations of dates that can make sense in any case, depending on who you’re asking. As I mentioned, it’s not what makes sense to you but your user. Having people misunderstand dates is horrible, mainly because they can differ for months (think US and UK way of writing them).
And since Power Automate provides a way to correctly display the dates, days of the week, and months, there’s no real reason not to take advantage of it and be friendly to your users.
Photo by Paul Green on Unsplash
Thank you for the credit, Manuel :-)!
My pleasure :). Your solution was better!