cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Power_Automater
Helper IV
Helper IV

Using Compose with formatDateTime & utcNow

I am using a Compose action to take a dynamic content date value (from a SP list):

 Power_Automater_1-1659938263814.png

 

And then I use this in a Create/Update Event action to set the start date with:

formatDateTime(outputs(
'Compose'),'yyyy-MM-ddTHH:mm:ss'

Power_Automater_2-1659938346440.png

 

The problem is that the date and time I get in the Compose action is the incorrect timezone so by the time it is added into the event action it is wrong. Should I change what I put into the Compose action or update the expression used for start time, and if so how?

1 ACCEPTED SOLUTION

Accepted Solutions
Rhiassuring
Super User
Super User

You don't need to point at your Compose, you can call out your field. If you're going to use a field that will only have one output (like a single form response), it will look like this:

 

formatdatetime(convertTimeZone(outputs('Get_items')?['body/value'][0]?['Created'],'UTC','Pacific Standard Time'),'yyyy-MM-dd')
 
The [0] lets you get the only item in the array that is returned, since it's a single item. No need to go into an Apply to Each. And the ['Created'] is where you type whatever column you want.
 
If you are doing it in an Apply To Each (when there are multiple returns), it will look like this, inside of the Apply to Each:

formatdatetime(convertTimeZone(items('Apply_to_each')?['Created'],'UTC','Pacific Standard Time'),'yyyy-MM-dd')
 
Rhiassuring_0-1660183169198.png

 

View solution in original post

5 REPLIES 5
Rhiassuring
Super User
Super User

Hi there, 

 

You can use the "convertTimeZone()" action in your compose, on your dynamic content. You might have something like convertTimeZone(yourfield,'UTC','Pacific Standard Time'). That should take care of it!

Thank you for that @Rhiassuring , so if I were to add the compose to this it would look like this?

convertTimeZone(outputs('Compose'),'UTC','Pacific Standard Time')

Also, where would I put the date format string part?

Rhiassuring
Super User
Super User

You'd put it on the outside of that - like this: 

 

formatdatetime(convertTimeZone(utcNow(),'UTC','Pacific Standard Time'),'yyyy-MM-dd')

(In my example I'm using utcNow() instad of a field, just to be clear)
Power_Automater
Helper IV
Helper IV

So with the compose it would be like this?

formatdatetime(convertTimeZone(outputs('Compose'),'UTC','Pacific Standard Time'),'yyyy-MM-dd')

Rhiassuring
Super User
Super User

You don't need to point at your Compose, you can call out your field. If you're going to use a field that will only have one output (like a single form response), it will look like this:

 

formatdatetime(convertTimeZone(outputs('Get_items')?['body/value'][0]?['Created'],'UTC','Pacific Standard Time'),'yyyy-MM-dd')
 
The [0] lets you get the only item in the array that is returned, since it's a single item. No need to go into an Apply to Each. And the ['Created'] is where you type whatever column you want.
 
If you are doing it in an Apply To Each (when there are multiple returns), it will look like this, inside of the Apply to Each:

formatdatetime(convertTimeZone(items('Apply_to_each')?['Created'],'UTC','Pacific Standard Time'),'yyyy-MM-dd')
 
Rhiassuring_0-1660183169198.png

 

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (3,591)