Difference in minutes and seconds between two date
Options
Maxime_F67
Registered Posts: 2 ✭✭✭✭
Hi everyone,
How can I get the difference in "hours" "minutes" AND "seconds" (example: 14:30:24) from two date?
Example:
Col 1: 20180101T09:50:15.000Z
Col 2: 20180101T10:07:55.000Z
Col 3 (difference): 00:17:40
Thank so much for your help
Maxime
How can I get the difference in "hours" "minutes" AND "seconds" (example: 14:30:24) from two date?
Example:
Col 1: 20180101T09:50:15.000Z
Col 2: 20180101T10:07:55.000Z
Col 3 (difference): 00:17:40
Thank so much for your help
Maxime
Tagged:
Answers

Hello Maxime,
You can for example use a Prepare recipe to compute the time difference between two columns (these dates have to be parsed). For this, you can use the processor "Compute difference between two dates" in the Prepare recipe and select the two columns.
You can define the granularity of the output right in the new step (from years to seconds).
I hope this helps!
Have a nice day.
Pauline 
Hello,
Thank you for your answer but with the processor "Compute difference between two dates" the output time unit is hours or minutes or seconds but cannot be hours:minutes:seconds. 
Indeed! Thanks for replying. I tried this on my side and it seems to be working stillusing the formula in a Prepare recipe.
The idea is to rebuild the date with hours:minutes:secondes, from the time difference in seconds.
"00"[0,2(floor(diff(date1, date2, "seconds")/3600)).length()] + (floor(diff(date1, date2, "seconds")/3600))
+ ':'
+ "00"[0,2 (floor(mod(diff(date1, date2, "seconds"), 3600)/60)).length()] + (floor(mod(diff(date1, date2, "seconds"), 3600)/60))
+ ':'
+ "00"[0,2 (mod(mod(diff(date1, date2, "seconds"), 3600),60)).length()] + (mod(mod(diff(date1, date2, "seconds"), 3600),60))
You can obviously use a Python recipe instead of the formula to rebuild this field too.
I hope this helps.
Have a nice day,
Pauline