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

Date Format for emails assistance please

I have to say I cannot stand the current way to change date formats in the emails in power automate. So much easier in SP Designer. This whole add a string variable for each column is crazy ridiculous. I have an email with 6 dates I need added into an email. All of them show this wrong way format of YYYY-MM-DD. Even though the list in Sharepoint says MM-DD-YYYY. Why cannot automate just read THAT setting? Also if not that why not let people add the column into the body of the email and THEN just click on that column in email body and change it with a simple click option? This is a bad setup currently. Can ANYONE help me get all 6 of my date columns added into an email so I can get this email out to our users? Adding a variable string for 6 different columns is stupid quite honestly. Any help would be appreciated. Is there and easier way for this?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@RobertVT  so i understand that you want to use departure date in the expression, please try below expression in that case, the only change is it has DepartureDate name with you space in between.

formatDateTime(triggerOutputs()?['body/DepartureDate'],'MM-dd-yyyy')

If above expression doesn't work, then your Departure Date column internal name may be different, so first you will need to get internal name of your column, so go to your list, click on list settings from the gear button on top right corner. On List Settings page, click on the column, so you will be taken to column settings page, now look at the browser url, you will see ?Field= and there will be a name after ?Field= use that name in expression in place of DepartureDate in above expression.

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

View solution in original post

5 REPLIES 5
annajhaveri
Super User
Super User

@RobertVT  you can use below expression to format the date directly in the Send Email action using Dynamic Content -> Expression (without creating variable), see screenshot below

formatDateTime(triggerOutputs()?['body/Created'],'MM-dd-yyyy')

 

annajhaveri_0-1624019395696.png

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

OK that is fine for Create Date.... I have two I need this for in one of my emails and one where I need this like 6 times. So I looked at your expression and I changed it. So in one in email I use the Column "Departure Date" so I went down into the body next to the line I typed in "Departure Date: and added this expression: "

 

 

 

formatDateTime(triggerOutputs()?['body/Departure Date'],'MM-dd-yyyy')

 

 

 

 

Thinking this would change the date format for DEPARTURE DATE to show like the one you showed. I am getting all kinds of template errors. What gives here? It would seem the expression logic would be easy, change the column from Created to Departure Date. And yes this is the correct name of the Column in the Sharepoint site.

 

What am I doing wrong here?

I am getting this error in the running of the FLOW:

Unable to process template language expressions in action 'Send_an_email_(V2)' inputs at line '1' and column '13953': 'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.

RobertVT
Regular Visitor

Here is my email body:

RobertVT_0-1624648798274.png

 

@RobertVT  so i understand that you want to use departure date in the expression, please try below expression in that case, the only change is it has DepartureDate name with you space in between.

formatDateTime(triggerOutputs()?['body/DepartureDate'],'MM-dd-yyyy')

If above expression doesn't work, then your Departure Date column internal name may be different, so first you will need to get internal name of your column, so go to your list, click on list settings from the gear button on top right corner. On List Settings page, click on the column, so you will be taken to column settings page, now look at the browser url, you will see ?Field= and there will be a name after ?Field= use that name in expression in place of DepartureDate in above expression.

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

View solution in original post

I want you to know this worked and yes I did not need variable strings. I will tell you this IS NOT a user friendly way of changing something like a date format. I went back to correct the current one in the email and every time I clicked the current formatted date expression and edited it and hit OK it disappeared but somehow it saved it without any confirmation. Very confusing. Still, you were right, I needed the exact name of the column and since the column name was created with  spaces I need the full correct one from the column link. I am good now and it is working. Thank you again and while this isn't user friendly and Microsoft needs to do some serious work on simple edits like this, your answer worked and I truly appreciate the assistance.

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

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,994)