cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
p_doc
Helper III
Helper III

AI model: Date extraction from Invoice

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.

1 ACCEPTED SOLUTION

Accepted Solutions
CedrickB
Power Apps
Power Apps

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.

View solution in original post

6 REPLIES 6
CedrickB
Power Apps
Power Apps

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.

p_doc
Helper III
Helper III

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.

kv
Helper II
Helper II

Thank you, @CedrickB . Understood, I need to do further processing in order to obtain the date / number.

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Top Solution Authors
Users online (1,207)