“I’ve got a date in my local format, but I have to convert it to ISO to save it into SharePoint, what’s the easiest way to do it in Power Automate?”
Whenever you work with dates in Power Automate, you should use them in the ISO format: yyyy-MM-dd. If you use a date in a different format, the flow won’t work. The Filter query won’t return the expected results, the conditions won’t be evaluated correctly…
Yet often you don’t get the date directly in the ISO format. Your date can be in your local format, e.g. dd.MM.yyyy for the Czech Republic. Or it can have the month, date and year in different order, e.g. MM-dd-yyyy, or a different separator. But whatever the format is, if it’s not an ISO date you should convert it.
You can combine multiple expressions…
One way to convert the date is to use the concat(…) and split(…) expressions. Split(…) the date into separate pieces, and reorder them using their index. Then build the new date again with the concat(…) expression. For example:
Date: 01/13/2022
Format: MM/dd/yyyy
concat(split('01/13/2022','/')[2],'-',split('01/13/2022','/')[0],'-',split('01/13/2022','/')[1])
But that’s not the easiest solution.
…or use a single parseDateTime(…) expression instead!
The easiest solution is to use the parseDateTime(…) expression. This expression can take any date and convert it to the ISO date. It expects three parameters: the date to convert, the locale of the date, and the format of the provided date.
parseDateTime(<date>, <dateLocale>, <dateFormat>)
Note: <…> are placeholders, replace them including the < and >.
For example, to convert a date from the Czech date format to ISO…
parseDateTime('13.01.2022','cs-CZ','dd.MM.yyyy')
… or reorder an English date and replace the separator.
parseDateTime('01/13/2022','en-US','MM/dd/yyyy')
Both of the examples above will give you the date in the ISO format, which you can use in your flow or reformat as needed.
2022-01-13T00:00:00.0000000
Summary
Power Automate gives you (at least) two options how to convert any date to an ISO date. You can do it either step by step with the split(…) expression, index, and the concat(…) expression, or with a single parseDateTime(…) expression. I prefer the latter since I learned about the expression’s existence.
hi
this is great. but how will I know what format will be passed to my flow if I dont know what language settings are used on the users browser?
The reason my flow stopped working was because on my excel, the date passed to my flow was yyyy-mm-dd
But my colleague tried and their excel passed the date as dd/mm/yyyyy