cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pete_whitfield
Level: Power Up

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

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





If anyone is trying to help you with an issue, the fastest way to say thanks is by kudoing. Be grateful, Thumbs up!

Proud to be a Flownaut!





Community Support Team
Community Support Team

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

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!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,580)