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

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 IV
Helper IV

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

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.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Top Solution Authors
Users online (4,921)