Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 15th, 2003, 09:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
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\">
Reply With Quote
  #2 (permalink)  
Old December 16th, 2003, 12:26 PM
Authorized User
 
Join Date: Jun 2003
Location: , Quebec, Canada.
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
Reply With Quote
  #3 (permalink)  
Old December 16th, 2003, 07:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:15 PM.


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