cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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
efialttes
Super User
Super User

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!



v-xida-msft
Community Support
Community Support

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
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.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (2,525)