Showing results for 
Search instead for 
Did you mean: 
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


Super User
Super User


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


Hope this helps

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

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

Escribo sobre Power Automate en:

Proud to be a Flownaut!

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:



Best regards,


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

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,993)