Hi,
I am currently working on an AI model where it extracts information from Invoices and passes this information to Power automate flow, which then stores information in excel.
In one of the Invoice collection, the model captures date correctly i.e. 11/08/2021
But while storing this date information in Excel, it changes the format to 8/11/2021
For other invoice collection, the AI model is storing the date information correctly.
Does anyone know what is wrong with my flow, why is it changing the date format for only 1 invoice collection?
Any help is appreciated.
Solved! Go to Solution.
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.
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.
Hi @CedrickB ,
Thank you for that.
Quick questing, how do you define the AI model to understand the capture data is European or US format.
I have 50 collection of invoice and some have European format and some have US format date.
Is there a way to define it?
Unfortunatelly, it is not possible at the moment.
Any update on the locale of the date and number parsing? I'm currently having problems with parsing commas in numbers and dates.
There is no built-in way to perform this.
So you should create some customization logic depending on your use case
1. If you always have the same number format, you can apply some text parsing function with a method similar as above with dates.
2. If you have inconsistent number,.you can have store the information of the locale by vendor in a table. When the vendor name is extracted, you perform a look up to this table to get the locale and apply the appropriate text parsing logic.
Thank you, @CedrickB . Understood, I need to do further processing in order to obtain the date / number.