473,396 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Time difference

Hi

I am trying to find difference between two time values in hours. I have
tried the following?

? dateDiff("h", #23:00:00#, #23:00:00#) gives 0 as expected.

? dateDiff("h", #00:00:00#, #23:00:00#) gives 23??? should it not be 1 as
00:00:00 (12 midnight) is only one hour after 23:00:00 (11 pm)?

? dateDiff("h", #01:00:00#, #23:00:00#) gives 22. Should it not be 2 as
01:00:00 (1 am) is two hour after 23:00:00 (11 pm)?

What is going on? How can I get the desired time difference values?

Thanks

Regards
Nov 13 '05 #1
2 4016
The Date type in Access is intended to store a timestamp: a complete date
and time, not just a time. You need to recognize that a Date field is an 8
byte floating point number, where the integer part represents the date as
the number of days relative to 30 Dec, 1899, and the decimal part represents
the time as a fraction of a day.

When you've got #00:00:00#, Access sees this as 0.0. When you've got
#23:00:00#, Access sees this as 0.9583333. In other words, it sees both
times as being on the 30th of Dec, 1899. Therefore, 23 hours is correct for
the first one, and 22 hours for the second one.

Either include the date in your values, or use the kludge shown in
http://www.mvps.org/access/datetime/date0008.htm at "The Access Web"

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:40***********************@news-text.dial.pipex.com...
Hi

I am trying to find difference between two time values in hours. I have
tried the following?

? dateDiff("h", #23:00:00#, #23:00:00#) gives 0 as expected.

? dateDiff("h", #00:00:00#, #23:00:00#) gives 23??? should it not be 1 as
00:00:00 (12 midnight) is only one hour after 23:00:00 (11 pm)?

? dateDiff("h", #01:00:00#, #23:00:00#) gives 22. Should it not be 2 as
01:00:00 (1 am) is two hour after 23:00:00 (11 pm)?

What is going on? How can I get the desired time difference values?

Thanks

Regards

Nov 13 '05 #2
"John" <jo**@nospam.infovis.co.uk> wrote in
news:40***********************@news-text.dial.pipex.com:
Hi

I am trying to find difference between two time values in
hours. I have tried the following?

? dateDiff("h", #23:00:00#, #23:00:00#) gives 0 as expected.

? dateDiff("h", #00:00:00#, #23:00:00#) gives 23??? should it
not be 1 as 00:00:00 (12 midnight) is only one hour after
23:00:00 (11 pm)?
From the helpfile,
If date1 refers to a later point in time than date2, the
DateDiff function returns a negative number.

Since you are not getting a negative, the calculations are
correct. Start at midnight and finish at 11pm is a 23 hour event.

If you want start at 23:00 finish at 00:00, invert the order of
the times. Since Access will assume the same date, it will return
a negative value in the case of 23:00 to 00:00. test if the
interval is negative and add 24 if necessary. Otherwise, you can
include dates in the inputs to the function.
Bob Quintal

? dateDiff("h", #01:00:00#, #23:00:00#) gives 22. Should it
not be 2 as 01:00:00 (1 am) is two hour after 23:00:00 (11
pm)?

What is going on? How can I get the desired time difference
values?

Thanks

Regards


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jason Reljac | last post by:
Howdy, For a project I am working on right now I need to be able to calculate the time difference between to given times. (For example...The difference between 11:30 am and 1:45pm being 2:15) ...
10
by: Andreas | last post by:
Hi! Is it possible to get a time event at a specific time, for instance eight a'clock? My program is running in the background and is minimized to the tray bar. If not, is there a smooth way...
2
by: Joe User | last post by:
I am looking to calculate the difference between and event time and a sample time of Now. This is the query that I thought would do it, however I'm returning DIFFERENCE values that look the same...
6
by: cournape | last post by:
Hi there, I have some scientific application written in python. There is a good deal of list processing, but also some "simple" computation such as basic linear algebra involved. I would like to...
6
by: Michael Bulatovich | last post by:
I have a very simple db I use for keeping track of hours, tasks, projects, clients etc. It has a form that I use to enter data. Currently the form has a textbox for a field called "start time",...
7
by: Edward Mitchell | last post by:
I have a number of DateTimePicker controls, some set to dates, some set to a format of Time. The controls are all embedded in dialogs. I created the controls by dragging the DateTime picker from...
5
by: Geoff Jones | last post by:
Hi I have question regarding times and dates in a datatable. I have one table with one column having the date e.g.03/09/04, and another column other the time 08:03:05. The other table has one...
3
by: Randall Parker | last post by:
Suppose one has a database of UTC times that are from different dates in the past. The problem with translating those times to a local time is that one does not know for each UTC time whether the...
3
by: Steve | last post by:
I am trying to calculate elapsed travel times for flights. My plan is to enter the local departure time, the departure city and the local arrival time and city. These times would be standardised...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.