cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

How to write an expression which extracts date text from email body

Hi Folks,

 

I am trying to write an expression that will extract, from the email body, the date given after 'Start Date' (in this example, 28th December) and add that date it to the 'Start Time' Field in 'Create event (V2)', and do the same for End Date.

 

Even if I could do that, would the date format be compatible or would I need to add a further expression to convert into an acceptable date format (and if so, what might that look like?)

 

The following leave request has been Approved by your line manager.

 

Employee: xxxx xxxxxxxx

Leave type: ANNUAL LEAVE

Start date: 28-DEC-17

End date: 28-DEC-17

 

Currently the best I can come up with is:

 

substring(body('Html_to_text'),add(lastIndexOf(body('Html_to_text'),'Start date '), 12),9

 

I'm a begginer at this so suspect that I'm some way off.  Any suggestions/help would be greatly appreciated.

 

Many thanks

Pete

2 REPLIES 2
Highlighted
Dual Super User III
Dual Super User III

Re: How to write an expression which extracts date text from email body

Hi

I think there is a missing parenthesis at the end of the expression

 

substring(body('Html_to_text'),add(lastIndexOf(body('Html_to_text'),'Start date'), 12),9)

 

In this link a similar scenario is described, also some date format limitations are detailed

https://powerusers.microsoft.com/t5/Building-Flows/formatDateTime-to-ISO-8061-format-for-Create-Even...

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Community Support
Community Support

Re: How to write an expression which extracts date text from email body

Hi @pete_whitfield,

 

I agree with @efialttes’s thought almost, I have made a test on my side and please take a try with the following workaround:2.JPG

Within “Start date” action (Compose action), Inputs set to following formula:

substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'Start date'),12),9)

Within “End date” action (Compose action), Inputs set to following formula:

substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'End date'),10),9)

 

The flow works successfully as below:3.JPG

 

More details about expressions which could be used in Microsoft Flow, please check the following article:

https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language#functions

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (7,674)