cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
G99
Post Prodigy
Post Prodigy

Remove time formatting when sending an email

Hello
I cannot get rid of this formatting when I send an email via flow using SharePoint list items:

 

2021-04-06T14:13:00Z

 

I tried the 'convert time zone' action, but unsure how I use the converted base time in my email.

 

I also tried the expression in the email body my value is "Date&Time" :

formatDateTime(Date_x0026_Time(),'MM/dd hh:mm tt')

Also want to change the formatting of the time to day/month/year
 
Thanks
1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Super User
Super User

Hi @G99 

 

Unfortunately, you have supplied the expression @formatdatetime(triggerBody()?[‘Date_x0026_Time’],’dd/MM/yyyy’) as a string so it does not evaluate.

 

triggerbody() also suggests that Date_x0026_Time comes from your reoccurrence trigger?  I suspect it is from get items?

 

If I do compose value:

 

DamoBird365_4-1617801217602.png

 

 

I get the whole array of values for get items

 

DamoBird365_5-1617801281135.png

 

If I want to get Accessory from the body I must use

outputs('Get_items')?['body/value']?[0]?['Accessory']
 
DamoBird365_7-1617801318540.png

 

Returns: 

 

DamoBird365_6-1617801300593.png

 

 

Note this will return the 1st Accessory key/value from the Array as an array may contain multiple accessory key/values.  
 
If I was to try outputs('Get_items')?['body/value']?['Accessory'] I would get an error about selecting elements using an integer value.
 
This will hopefully all apply to your date time too - assuming it is a column in your list.
 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

 

 

View solution in original post

6 REPLIES 6
DamoBird365
Super User
Super User

Hi @G99 

 

I've covered some of the datetime formatting here in a recent blog.

 

You are right to be considering formatdatetime however I would check how you have called your dynamic content.  When you build an expression you can switch back to dynamic content and select an existing value, this will prevent you making an error with the variable or action output name.

 

An expression from Get Item for instance would be outputs('Get_item')?['body/Title'].  You appear to be simply listing the key name and nothing more.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

HI @DamoBird365 

 

Thanks
Slightly lost - and you are right, when I try to write FormatDateTime in the expression the only 2 options I have is body and value, and I am unable to select my field called Date&Time

I thought this would work, but again lacking the full understanding:

 

I create a 'Initialize variable' set it as vDateTime and 'Type' as String
When I come to set the variable, i can see the Date&Time in the value field, but as soon as as I do an expression and use

formatDateTime i'm no longer able to select the dynamic content.
 
I can type in the following as a test:
formatDateTime(triggerBody()?['Date_x0026_Time'],'dd,MM,YYYY')
It saves, but when i run it I get an error:
 
Unable to process template language expressions in action 'Set_variable' inputs at line '1' and column '27563': 'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'.

Hi @G99 

 

triggerBody()?['Date_x0026_Time'] will be null because it's not tied to an actual value, you must have a typo in there somewhere.

 

If you can pick your date and time during the initialisation of a variable, you can then peek at the code (via elipses of the action) and you will be able to see the expression for the field you are referring to.  There's no need for a variable but if you are new, this is a good way to learn as it will still run.  In fact, you could call your variable with formatdatetime but make sure you build the formatdatetime in the expression builder and then switch back to the dynamic content tab when you are ready to choose the dynamic value you are looking to apply the formatdatetime expression on.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

 

G99
Post Prodigy
Post Prodigy

Hi @DamoBird365 

 

Hmm, havent played around with Flow as much as I'd like

I've tried to do the following but still doesnt work:

 

After get Items action
I have a Initilize variable, Called vDateTime
Type: String
in the value I had set it as null, so thought this is where I set the value, I can select Date&Time but as soon as I click Expression and type in FormatDateTime() clicking inside the brackets I only have 2 options in dynamic content body and value.... clearly im missing the bigger picture here

G99
Post Prodigy
Post Prodigy

@DamoBird365 
I have also tried the following:

G99_0-1617797178037.png

It works, but with this set up in the Compose inputs I have:
@formatdatetime(triggerBody()?[‘Date_x0026_Time’],’dd/MM/yyyy’)

When i get the email all I get is:

 

@formatdatetime(triggerBody()?[‘Date_x0026_Time’],’dd/MM/yyyy’)

 

Rather than the actual date, both the above things should work, but I cannot spot what I am doing wrong

DamoBird365
Super User
Super User

Hi @G99 

 

Unfortunately, you have supplied the expression @formatdatetime(triggerBody()?[‘Date_x0026_Time’],’dd/MM/yyyy’) as a string so it does not evaluate.

 

triggerbody() also suggests that Date_x0026_Time comes from your reoccurrence trigger?  I suspect it is from get items?

 

If I do compose value:

 

DamoBird365_4-1617801217602.png

 

 

I get the whole array of values for get items

 

DamoBird365_5-1617801281135.png

 

If I want to get Accessory from the body I must use

outputs('Get_items')?['body/value']?[0]?['Accessory']
 
DamoBird365_7-1617801318540.png

 

Returns: 

 

DamoBird365_6-1617801300593.png

 

 

Note this will return the 1st Accessory key/value from the Array as an array may contain multiple accessory key/values.  
 
If I was to try outputs('Get_items')?['body/value']?['Accessory'] I would get an error about selecting elements using an integer value.
 
This will hopefully all apply to your date time too - assuming it is a column in your list.
 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

 

 

View solution in original post

Helpful resources

Announcements
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,560)