DateTimeDiff() function using hours, minutes
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Labels:
- Date Time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Yes, of course. I was double counting. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I was suggesting just using DateTimeDiff(...minutes)/60 and forgetting the hours part as no need to do it twice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
1.25 hours, which is what i want. I dount want hours and minutes, which your modulo function would allow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
