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
Solved! Go to Solution.
Yes, of course. I was double counting. Thank you.
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?
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
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