Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 15th, 2003, 09:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default Wierd Date Calculations

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:
Code:
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
__________________
<hr noshade size=\"1\"><i><font color=\"blue\">I am a loud man with a very large hat. This means I am in charge</i></font id=\"blue\">
 
Old December 16th, 2003, 12:26 PM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old December 16th, 2003, 07:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Calculations edove ASP.NET 2.0 Basics 0 March 30th, 2007 07:05 AM
Date Calculations scourge SQL Server 2000 9 May 11th, 2006 05:08 AM
Date Calculations Stu_morris40 Infopath 0 November 1st, 2005 11:53 AM
wierd error crmpicco Javascript How-To 1 August 8th, 2005 10:50 AM
Date Calculations mvollmer Classic ASP Databases 4 October 15th, 2003 10:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.