Alteryx Designer Desktop Discussions

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

How to find the difference (HHmm) between two separate times (HHmm).

deckthehalls
7 - Meteor

Hello all, 

 

I am trying to figure out a formula that can easily figure out the difference between two times (HHmm) in Alteryx. Military time is what I need to use. (1530-930 = 6 hours) Visual example below: 

 

Start TimeEnd TimeDifference 
93015306

 

5 REPLIES 5
Luke_C
17 - Castor

Hi @deckthehalls 

 

This formula should do the trick. It parses each time into an alteryx read-able format and then applies the datetimediff function. The below link is super helpful in breaking down each datetime function.

 

DateTime Functions | Alteryx Help

 

Datetimediff(
Datetimeparse(padleft(tostring([End Time]),4,'0'),'%H%M'),
Datetimeparse(padleft(tostring([Start Time]),4,'0'),'%H%M'),'hours')

 

Luke_C_0-1650908831079.png

 

 

binuacs
20 - Arcturus

@deckthehalls Another way of doing this with the DateTime Tool

binuacs_0-1650920948146.png

 

deckthehalls
7 - Meteor

This worked perfectly for what I needed. Thanks!

Luke_C
17 - Castor

@deckthehalls Happy to help! Don't forget to mark the solutions so others can find them easier. 

fharper
12 - Quasar

@deckthehalls please do mark the answer you like as a solution as it helps others find answers faster and respects the assistance provided by the contributor

Labels