adding an interval to medium time control

  • Thread starter Thread starter BRC
  • Start date Start date
B

BRC

I have read about 50 posts on calculationing date and time values but
cannot almost all deal with datediff functions. I have a control with
medium time value. I would like to add 3 hrs to that value but i don't
quite understand how access stores these values. I have read that all
date/time functions store both date and time. In my case I have the
field in the table formatted as medium time and the controls on the
from formated as medium time. Thanks in advance for any suggestions.
BRC
 
How a field is formatted doesn't impact how it's stored at all.

Date/Time values in Access are stored as 8 byte floating point numbers,
where the integer portion represents the date as the number of days relative
to 30 Dec, 1899, and the decimal portion represents the time as a fraction
of a day. If all you're storing is a time, Access treats it as that time on
30 Dec, 1899. If you're trying to store a duration, you're using the wrong
data type.
 
Date/Time data types can store date and time values. The format of the data
is actually a floating point numeric value. The whole number represents a
number of days starting from Dec 31, 1899. The fractional part of the value
represents the number of seconds since midnight of the date represented by
the whole number part.

A Date/Time field or variable can contain a date only, the time only, or
both. If you are working with dates only, you will want to use the Date()
Function. If you need to include the time, you will want to use the Now()
Function which includes Date and Time. If you want to use time only, use the
Time() Function.

This can be important when comparing dates. If you include time with the
date and compare on the date only, the comparision may give incorrect results
because it will be comparing the entire field or variable with the time
component.


As far as working with that value, you don't need to. The intrinsic date
functions built into Access do that for you.

Regardless of the date format you use, the data is the same. The format
only determines how the value will displayed for human consumption. So if
you need to add three hours to a date, you use the dateadd function:

SomeTime = DateAdd("h", 3, OtherTime)

Read the help in VBA on the date functions for details on the arguments and
how they work.
 
The fractional part of the value
represents the number of seconds since midnight of the date represented by
the whole number part.

nitpick: actually fractions of a day, not seconds since midnight. 0.5 means
noon, 0.75 is 6pm, etc.


John W. Vinson [MVP]
 
John W. Vinson said:
nitpick: actually fractions of a day, not seconds since midnight. 0.5
means
noon, 0.75 is 6pm, etc.

Heck, if you're going to pick nits, how about chastising him for the
previous sentence too: "The whole number represents a
number of days starting from Dec 31, 1899" It's the number of days starting
at Dec 30, 1899. <g>
 
Heck, if you're going to pick nits, how about chastising him for the
previous sentence too: "The whole number represents a
number of days starting from Dec 31, 1899" It's the number of days starting
at Dec 30, 1899. <g>

And the traditional Are You Really An Access Geek question:

Why December 30, not December 31?

John W. Vinson [MVP]
 
Back
Top