cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CMcCubbin
Regular Visitor

Format Date Time expression gives back error message on syntax

In my flow when sending an email with a date it is shown as yyyy/MM/dd. I want to change the format to dd/MM/yyyy. I tried converting the format using this Data String:

 

formatDateTime(triggerBody()?['_Hidden_VacationStartDate'],'dd/MM/yyyy')
 
However, I always get this error message: 
 
InvalidTemplate. InvalidTemplate. Template language expressions in the entries of the action "Write" in line "1" and column "2866" cannot be processed: The template language function "formatDateTime" expects a parameter of type "string" as first parameter. The specified value is of type "zero".
 
The date I want to convert is in a sharepoint list in the column named _Hidden_VacationStartDate.
 
Thank you!
1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

 

Hi @CMcCubbin ,

 

Please try the following method:

10.PNG

Put the Date field in Compose, then use the formatDateTime() function to format the output of Compose, and then configure the formatted value in the email body.

 

In Flow run history, you can view the output of Compose to see if the value of this field is valid and the format is as expected.

 

Please take a try again.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

18 REPLIES 18
abm
Super User III
Super User III

Hi @CMcCubbin 

 

Change the format expression to

 

formatDateTime(string(triggerBody()?['_Hidden_VacationStartDate']),'dd/MM/yyyy')

 

If this doesn't work add a compose and map the triggerBody()?['_Hidden_VacationStartDate'].  Run the flow and see what values are returned from run history.

 

Thanks

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials
CMcCubbin
Regular Visitor

Hi @abm 

 

thank you. I tried to use your data string in the compose step, but I still get the same error message back.

 

Do you have another idea?

 

Thanks

 

abm
Super User III
Super User III

Hi @CMcCubbin 

 

Did you tried my second option which I mentioned earlier?

 

Add a compose and map the trigger date field. Check the run history. See what values are returned?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials
CMcCubbin
Regular Visitor

Hi @abm,

 

I'm not sure I understand what you mean with mapping.

 

I added a compose and added as expression: 

 

formatDateTime(string(triggerBody()?['_Hidden_VacationStartDate']),'dd/MM/yyyy')

 

Screenshot 1.PNG

 

When testing the flow, I only get a error message back and no values:

 

"InvalidTemplate. Template language expressions in the entries of the action "Write" in line "1" and column "2867" cannot be processed: An invalid value was specified for the date/time string "" in the function "formatDateTime". The datetime character string must correspond to the ISO 8601 format."

 

Screenshot 2.PNG

 

Thank you!

 
abm
Super User III
Super User III

Is this field optional?

 

if(empty(triggerBody()?['_Hidden_VacationStartDate']), triggerBody()?['_Hidden_VacationStartDate'], formatDateTime(triggerBody()?['_Hidden_VacationStartDate'] 'dd/MM/yyyy'))

 

The error is related to the data what you getting in flow. Did you checked the runtime history what values are returned?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials
CMcCubbin
Regular Visitor

@abm 

 

The field is mandatory.

 

When I check the runtime history, I get back the date of  _HiddenVacationStartDate in the format yyyy-MM-dd the step prior to compose (which is create item). In the compose step, there is just the error text.

 

 

 

Thank you!

 

 

hi @CMcCubbin  please try converting your value before compose.

 

convert.PNG



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
abm
Super User III
Super User III

Hi @CMcCubbin 

 

Looks like your expression is not right. Could you post a screenshot of your expression.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

@ChristianAbata 

 

It now returns the date in the format M/d/yyyy even though I specified it to be in the format dd/M/yyyy:

 

Screenshot 5.PNGScreenshot 4.PNG

 

 

Thanks!

CMcCubbin
Regular Visitor

@abm 

 

the whole string is: 

formatDateTime(string(triggerBody()?['_Hidden_VacationStartDate']),'dd/MM/yyyy')
 
Screenshot 6.PNG

@CMcCubbin  please try to use that returned value to change it with the formatdtetime expresion,

 

coma.PNG



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

@abm @ChristianAbata 

 I now did the following:

 

Convert time zone -> compose -> send approval

 

I don't get an error message now on the compose part, but the date format still doesn't change:

 

Screenshot 7.PNG

abm
Super User III
Super User III

Hi @CMcCubbin 

 

Believe you adding the expression as plain text here. You need to click the dynamic content expression and paste the text then click ok.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

@CMcCubbin  string is bad closed see you need ) before your coma



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
abm
Super User III
Super User III

Hi @CMcCubbin 

 

See below.

 

image.png



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

Hi  @CMcCubbin 

 

Like @ChristianAbata  mentioned the  brackets are missing. If you have used the expression like I mentioned below it should have failed with an error. Believe you are using it as a plain text now. Follow my instructions below.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials
v-bacao-msft
Community Support
Community Support

 

Hi @CMcCubbin ,

 

Please try the following method:

10.PNG

Put the Date field in Compose, then use the formatDateTime() function to format the output of Compose, and then configure the formatted value in the email body.

 

In Flow run history, you can view the output of Compose to see if the value of this field is valid and the format is as expected.

 

Please take a try again.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @v-bacao-msft 

 

it works. Thank you!

 

 

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (80,635)