Subject: Wierd Date Calculations
Posted By: Steven Post Date: 12/15/2003 8:54:24 PM
I was just doing some date calculations, and was wondering if this happens to other people, and if so, does anyone know why.

Copy this into a module:
Function WierdThing()
Debug.Print DateDiff("n", #7/2/2003 12:15:00 AM#, #7/2/2003 1:55:00 AM#)
Debug.Print DateDiff("n", #11/15/2003 6:55:00 AM#, #11/15/2003 8:00:00 AM#)
Debug.Print DateDiff("h", #7/2/2003 12:15:00 AM#, #7/2/2003 1:55:00 AM#)
Debug.Print DateDiff("h", #11/15/2003 6:55:00 AM#, #11/15/2003 8:00:00 AM#)
End Function


The results I get are:
100
65
1
2

Which confuses me. For some reason, 100 minutes = one hour, but 65 minutes = 2 hours.

Any ideas why this happens?

Steven


I am a loud man with a very large hat. This means I am in charge
Reply By: stephanel Reply Date: 12/16/2003 11:26:21 AM
When you ask for the difference, DateDiff disregard the data inferior to the calculation interval.

So when you use this
Debug.Print DateDiff("h", #11/15/2003 6:55:00 AM#, #11/15/2003 8:00:00 AM#)
DateDiff use
Debug.Print DateDiff("h", #11/15/2003 6:00:00 AM#, #11/15/2003 8:00:00 AM#)


Stéphane Lajoie
Reply By: Steven Reply Date: 12/16/2003 6:44:08 PM
Excellent - I thought it might be something like that, and while I might not like it - at least I know what's happening, and can do a DateDiff("n" and divide it by 60 instead
Thanks Stéphane


I am a loud man with a very large hat. This means I am in charge

Go to topic 7431

Return to index page 985
Return to index page 984
Return to index page 983
Return to index page 982
Return to index page 981
Return to index page 980
Return to index page 979
Return to index page 978
Return to index page 977
Return to index page 976