Alteryx Designer

Find answers, ask questions, and share expertise about Alteryx Designer.
Register for the upcoming Live Community Q&A Session - and don't forget to submit your questions for @DeanS regarding the future role of analytics here.
SOLVED

DateTimeDiff() function using hours, minutes

Highlighted
7 - Meteor

I am unable to get the desired results with this function. I have a simple operation.  See below for a couple of examples:

DateTimeDiff(2015-01-29 06:00:00, 2015-01-28 13:15:00,   'hours') + DateTimeDiff(2015-01-29 06:00:00, 2015-01-28 13:15:00,   'minutes')/60 = 32.75   This clearly should be 16.75

DateTimeDiff(2015-01-28 09:15:00, 2015-01-28 06:00:00, 'hours') + DateTimeDiff(2015-01-28 09:15:00, 2015-01-28 06:00:00, 'minutes')/60 = 6.25        This clearly should be 3.25

 

Please tell me what I am doing wrong.

 

Thanks,

Peter

Highlighted
16 - Nebula
16 - Nebula

The DateDiff function is giving you the total number or hours (16) and total number of minutes (1005)

 

I think the formula you want is:

 

DateTimeDiff([Field1], [Field2], "minutes")/60

Where Field1 and Field2 are your dates 

Highlighted
7 - Meteor

Yes, of course. I was double counting.  Thank you.

Highlighted
12 - Quasar

Peter

check this workflow

the probleom with your logic is you are dividing the Mins by 60 instead Modulo

i think the one i attached should work :)

 

thanks

Sar

Highlighted
16 - Nebula
16 - Nebula

I was suggesting just using DateTimeDiff(...minutes)/60 and forgetting the hours part as no need to do it twice.

Highlighted
12 - Quasar

so, How it will behave for the below dates

2015-01-28 06:00:00

2015-01-28 07:15:00

Should it be 1 hr 15 Mins or 1 Hr 25 Mins?

Highlighted
7 - Meteor

1.25 hours, which is what i want.  I dount want hours and minutes, which your modulo function would allow.

Highlighted
Alteryx Certified Partner

Hi Peter,

 

To find the difference in hours between the two (which i assume was what your desired output was?), i just used the second part of the expression.

 

DateTimeDiff(2015-01-29 06:00:00, 2015-01-28 13:15:00, 'minutes')/60 = 16.75

DateTimeDiff(2015-01-28 09:15:00, 2015-01-28 06:00:00, 'minutes')/60 = 3.25

 

If i've understood your question correctly, there isn't a requirement for the DateTimeDiff hours function. In the case of your formula, it is simply adding the difference in hours onto you result which has caused your outcome to be higher than expected.

 

Thanks,
Charlie

Highlighted
5 - Atom

I've read through this discussion and still am confused as I am not getting the correct answers.

I have 3 cases shown here and used 3 variations of the DateTimeDiff function.

My goal is to calculate the number of minutes between the 2 given dates.

When I check this with Excel, none of these are matching up.

Would someone please help me get this correct?
Thanks. Samuel Young

 

DateTimeDiff_Examples.JPG

Labels