Alteryx Designer Desktop Discussions

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

Need to calculate diff between time

sgaryali
8 - Asteroid

Hi,

 

I want to calculate diff between End time and start time.

 

What method I am using is replacing char ":" with "." but and the change the data type to number.

 

Which is giving result for few correctly but in case of 104

 

Where endtime is 5:15 and start time 2:45 by above method I am getting 2.7 as result.

 

But actually It should be 2.5 (2 hours 30 min)

 

How to get this?

 

 

Thank you in advance.

3 REPLIES 3
IraWatt
17 - Castor
17 - Castor

Hey @sgaryali,

One way to do this is convert it to the Alteryx Date Time format, then use a the datetime dif function in minutes then divide by 60 to get the hours:

IraWatt_0-1669799584458.png

If your interested in learning more about the datetime functions there is a great cheat sheet Blog here: https://community.alteryx.com/t5/Engine-Works/DateTime-Functions-Cheat-Sheet/ba-p/844353

 

Any questions or issues please ask

Ira Watt
Technical Consultant
Watt@Bulien.com 

Felipe_Ribeir0
16 - Nebula

Hi @sgaryali 

 

Please see if this works for you. I parsed the dates, so Alteryx can understand them as dates, calculated the time difference between then in seconds and them divided the result by 3600 (3600 seconds per hour).

 

DateTimeDiff(datetimeparse([ENDTIME], '%m/%d/%Y %H:%M'), datetimeparse([STARTTIME], '%m/%d/%Y %H:%M'), 'seconds')/3600

Felipe_Ribeir0_1-1669799654170.png

 

 

DenisZ
11 - Bolide

Please see attached workflow. 

 

DenisZ_0-1669801293749.png

 

 

I have created new DateTime variables which makes propably the rest of your program more dynamic. Then it is rather simple to calculate the difference in hours, minutes etc as you want. 

 

Hope this helps.

Labels