cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Super User
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 anybody solved your question, remember to mark its post as a solution!

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

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

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 Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 58 members 3,651 guests
Please welcome our newest community members: