cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Johns222
Helper I
Helper I

Needing help with writing a formula

Hi there 

 

I have a formula and it's getting the date from utc timezone. So right now it's a day behind my local time. The 'HH:mm' is fine because that is being pulled from a field in my dataverse, as you can see in the formula below.

 

It's also concatenating the date and time and if the variable is empty then it just outputs 'empty' to use later in a condition.  

 

So all I need to do is convert the date ('yyyy/MM/dd') to AUS Eastern Standard Time from utc so its the correct day on output of my variable, as mentioned right now its a day behind so I cant compare the variable with my local time. 

 

Here is what I attempted in writing out the formula - 

 

if(empty(items('Apply_to_each_Employee')?['fff_defaultstarttime']), 'Empty',convertFromUtc(concat(UtcNow('yyyy/MM/dd'), 'AUS Eastern Standard Time', ' ', formatdateTime(items('Apply_to_each_Employee')?['fff_defaultstarttime'], 'HH:mm'))))

 

Unfortunately I get this error -  'The template language function 'convertFromUtc' expects a timestamp as the first parameter, a target time zone as the second parameter, and an optional format string as the third parameter. The function was invoked with '1' parameter(s)

 

Thanks everyone in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Here are some examples that may help:

2021-11-10_23-51-14.png

 

 

Compose 2:
----------
convertFromUtc(utcNow(), 'AUS Eastern Standard Time', 'yyyy-MM-dd')
2021-11-11

Compose 3 with concat:
----------------------
convertFromUtc(utcNow(), 'AUS Eastern Standard Time', concat('yyyy-MM-dd','T17:52'))
2021-11-11T17:52

Compose 4 (make sure output of Compose 3 is a valid date/time
-------------------------------------------------------------
formatDateTime(outputs('Compose_3'),'hh:mm tt')
05:52 PM

 

 

 


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

7 REPLIES 7
ekarim2020
Super User
Super User

The expression needs to be modified like this so that it will convert from UTC to AUS time:

 

convertFromUtc(utcNow(),'AUS Eastern Standard Time','yyyy-MM-ddThh:mm')

 

 

2021-11-10_23-07-09.png


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

Ellis

Hi @ekarim2020 

 

Thanks for your message. 

 

So it's not possible to just change the Date from Utc? I need to take my HH:mm value from a field in dataverse thus I'm i am trying to concat converted current date and a time value taken from dataverse. Is it possible to write the formula like this? Also where would the concat fit in here? 

 

Thank you again. 

Here are some examples that may help:

2021-11-10_23-51-14.png

 

 

Compose 2:
----------
convertFromUtc(utcNow(), 'AUS Eastern Standard Time', 'yyyy-MM-dd')
2021-11-11

Compose 3 with concat:
----------------------
convertFromUtc(utcNow(), 'AUS Eastern Standard Time', concat('yyyy-MM-dd','T17:52'))
2021-11-11T17:52

Compose 4 (make sure output of Compose 3 is a valid date/time
-------------------------------------------------------------
formatDateTime(outputs('Compose_3'),'hh:mm tt')
05:52 PM

 

 

 


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

and also (which I think is what you originally meant):

 

convertFromUtc(concat(utcNow('yyyy-MM-dd'),'T00:22Z'), 'AUS Eastern Standard Time', 'yyyy/MM/dd hh:mm tt')

 

ekarim2020_0-1636590558765.png

ekarim2020_1-1636590590811.png

 

 

 


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

Johns222
Helper I
Helper I

Hi @ekarim2020 

 

Thanks for that it pointed me in the right direction. 

 

I have created this expression- 

('compose date' holds the converted date and 'time check Variable' I just need the time)

 

if(empty(items('Apply_to_each_Employee')?['fff_defaultstarttime']), 'Empty', formatDateTime(concat(outputs(‘Compose Date’), ' ', outputs(‘Time Check Variable'), 'HH:mm')))

 

But I get a pop up telling me that my expression is invalid. Is there anything that stands out to you? 

 

Johns222
Helper I
Helper I

Nevermind I used -

if(empty(items('Apply_to_each_Employee')?['fff_defaultstarttime']), 'Empty', concat(variables('Compose Date'), ' ', formatDateTime(items('Apply_to_each_Employee')?['fff_defaultstarttime'], 'HH:mm:ss')))
 
Thanks!!

If this will suit your needs, uou can a null value instead of the text 'Empty',

2021-11-11_11-06-28.png

Ellis

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

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

Power automate tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

Users online (2,104)