ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

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

DateTimeDiff() function using hours, minutes

petermc129
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

8 ANTWORTEN 8
jdunkerley79
ACE Emeritus
ACE Emeritus

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 

petermc129
Meteor

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

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

jdunkerley79
ACE Emeritus
ACE Emeritus

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

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?

petermc129
Meteor

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

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

sam_young
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

Beschriftungen
Top-Lösungs-Autoren