Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Calculate time (hours, minutes, seconds) between two dates

hholland
7 - Meteor

I have tried a couple different formulas however I can't get the output\result to be hh:mm:ss (example: 00:45:06)

This is the most currently formula I tried. DateTimeDiff([LogoutTime],[LoginTime],'%H:%M:%S'). I get an error that this will return a number and I have it set to Time. I changed the data type to string however then I get no results, even through the error is gone (just null in the field). 

 

This is my excel from excel, the Different column is what I would like to see.

Login Time = 04/19/21 8:55

Logout Time = 4/19/21 9:40

Difference = 00:45:06

6 REPLIES 6
apathetichell
19 - Altair

O.k. - datetimediff returns only one thing so it has to be seconds/minutes/hours etc... you can parse that as it is into a number or you can keep it as a time and then do a datetimeformat([whatever value you got above],"%H:%M:%S") to get it into a H:M:S: format.

Emil_Kos
17 - Castor
17 - Castor

Hi,

 

I have parsed the data into the date format:

 

Emil_Kos_0-1619640736517.png

 

For the diff in H M S In format, I am not sure how to do it quickly. 

 

Hope this helps at least a bit 🙂 

Emil_Kos
17 - Castor
17 - Castor

Hi,

 

False alarm 😀

 

I actually got it:

 

Emil_Kos_0-1619640987278.png

 

@apathetichell I missed your response... I am too tired I should get some sleep 🙂 

apathetichell
19 - Altair

@Emil_KosAll good!

 

@hhollandHere's how to think of it:

 

datetimeadd adds a unit of time to an amount of time the result is date/time.

datetimediff compares two date/times and comes back with the difference in a unit of time as expresses as the amount of units.

datetimeparse allows you to bring into date time a string based upon various formatting options

datetimeformat returns elemnts of a date time in a string format.

 

So the difference of two times - which you are looking for - is a number either in minutes/seconds/etc. you can then manipulate that into component parts and back into a time... using datetimeparse - or datetimeadd as shown by @Emil_Kos's superior workflow

 

hholland
7 - Meteor

Thank yo so much for your help. This is working great!

apathetichell
19 - Altair

Hi @hholland - could you mark @Emil_Kos and my solutions as correct? That will help future date/time users find this thread and get help.

Labels
Top Solution Authors