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

FormatDateTime does not work

Hello,

 

I would like to ask for help with formatDateTime function.

I want to transform recieved e-mail to Planner application. Everything works well except date for Due date field.

We have an e-mail template, where is a dedicated row which contain word "Termín" ("Date" in english) and after this word is placed a date. This date is taken as a Due date in Planner.

My problem is, that people in our company are used to use the date in format dd.(M)M.yyyy (eg. 13.7.2021), so I need to convert this date to ISO 8601 format.

I wanted to use function formatDateTime and convert it to format yyyy-MM-dd (eg. 2021-07-13).

But even I tried everything what I found, the results is still the same.

"Unable to process template language expressions in action 'Compose' inputs at line '1' and column '31949': 'In function 'formatDateTime', the value provided for date time string '15.07.2021' was not valid. The datetime string must match ISO 8601 format.'."

The weird fact is, that my flow works well 2 months ago, and I did not change anything in the flow.

 

Could anyone help me please?

 

My whole flow:

first.PNGlast.PNG

 

"Inicializovat proměnou 2" value: last(split(variables('EmailBody'),'Termín:'))

"Inicializovat proměnou 3" value: first(split(variables('EmailLast'),'<'))

"Due date" field value in Create task: if(contains(variables('EmailBody'),'Termín'),formatDateTime(variables('EmailFirst'),'yyyy-MM-dd'),getFutureTime(7,'day'))

 

Thank you in advance.

Libor

1 ACCEPTED SOLUTION

Accepted Solutions
ekarim2020
Super User
Super User

The function is expecting the date to be in the format MM.dd.yyyy in order to be able to convert it:
✔formatDateTime('7.13.2021''yyyy-MM-dd')
formatDateTime('13.7.2021', 'yyyy-MM-dd')
Are you able to re-format the date text so that it can be accepted by the formatDateTime function?
May be something similar to below?
ekarim2020_0-1626185751667.png

 

split(variables('varInputDate'),'.')
concat(variables('varSplitDate')[1],'.',variables('varSplitDate')[0],'.',variables('varSplitDate')[2])

 

ekarim2020_1-1626185837629.png

ekarim2020_3-1626185867937.png

 Ellis

View solution in original post

3 REPLIES 3
ekarim2020
Super User
Super User

The function is expecting the date to be in the format MM.dd.yyyy in order to be able to convert it:
✔formatDateTime('7.13.2021''yyyy-MM-dd')
formatDateTime('13.7.2021', 'yyyy-MM-dd')
Are you able to re-format the date text so that it can be accepted by the formatDateTime function?
May be something similar to below?
ekarim2020_0-1626185751667.png

 

split(variables('varInputDate'),'.')
concat(variables('varSplitDate')[1],'.',variables('varSplitDate')[0],'.',variables('varSplitDate')[2])

 

ekarim2020_1-1626185837629.png

ekarim2020_3-1626185867937.png

 Ellis

Hi ekarim2020,

 

Thank you very much for quick and great solution.

I had a few problems with settings, but now is everything ok and flow works as I expect.

 

Could I just ask, if the formatDateTime required a format MM.dd.yyyy for the whole time or if it was changed in the latest update? I ask, because few month ago, my flow worked alright even without your solution.

 

Thank you again.

Libor

ekarim2020
Super User
Super User

I don't believe that the formatDateTime function has changed in anyway.

This leads me to suspect that the source data (the time string) has changed in some way:  the e-mail template??

You may be able to obtain some useful info from the flow's 28-day run history, comparing when the it ran successfully before it "broke" to when it started to fail.  Compare the old time string from the e-mail template to the current one.

Ellis

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,271)