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

Using ticks to calculate the date difference not working

I am trying to use Ticks to calculate the time difference which can be in mins hours or days. 

 

here is the formulae i am using and i am trying to add this to a string 

div(sub(ticks(formatDateTime(utcNow(),'MM-dd-yyyy hh:mm:tt')),ticks(outputs('Start_and_wait_for_an_approval')?['body/completionDate'])),864000000000)

 

following is the error i am receiving at the flow 

 

InvalidTemplate. Unable to process template language expressions in action 'Append_to_string_variable_3' inputs at line '0' and column '0': 'In function 'ticks', the value provided for date time string '01-26-2022 06:34:PM' was not valid. The datetime string must match ISO 8601 format.'.

1 REPLY 1
Mister_Shaik
Super User
Super User

Hi @alearner090 ,

 

To get the ticks of utcNow(), you don't need to parse it, you can directly pass it to ticks(). Also, utcNow and completionDate should almost be same if you're using this action right after the approval action.

 

In case you are planning to get the time taken for an approval to complete you can use the outputs of approval, which are responseDate, requestDate and completionDate. Below I've used completionDate and requestedDate,

div(div(sub(ticks(outputs('Start_and_wait_for_an_approval')?['body/completionDate']),ticks(outputs('Start_and_wait_for_an_approval')?['body/requestedDate'])),10000000)

2. completion date.PNG

If you have some intermediary actions after the approval action and the time difference checker, then you can do as below

div(div(sub(ticks(utcNow()),ticks(outputs('Start_and_wait_for_an_approval')?['body/completionDate'])),10000000)

 

Hope you find this helpful! 🙂

 

Kind Regards,

Shaik Sha
________________________________________________________________________

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

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,998)