Hi,
String to date conversions are often akward.
11/08/2021 european format is also 8/11/2021 in US format.
The best way to handle it is to check the local of your Excel file and perform some parsing of the string before inserting to Excel.
So use below to capture
- DAY:
substring(variables('MyDate'), 0, indexOf(variables('MyDate'), '/'))
- MONTH:
substring(variables('MyDate'), add(indexOf(variables('MyDate'), '/'), 1), 2)
- YEAR:
substring(variables('MyDate'), add(lastIndexOf(variables('MyDate'), '/'), 1), 4)
Then if your Excel expects US format you can assemble it like that
concat(
substring(variables('MyDate'), 0, indexOf(variables('MyDate'), '/')),
'/',
substring(variables('MyDate'), add(indexOf(variables('MyDate'), '/'), 1), 2),
'/',
substring(variables('MyDate'), add(lastIndexOf(variables('MyDate'), '/'), 1), 4)
)
Swap the 1st and 3rd terms if European format is expected.
I hope it will help.