Re: Time Format in Excel
- From: John Nurick <j.mapSoN.nurick@xxxxxxxxxxxxxx>
- Date: Wed, 31 May 2006 18:22:42 +0100
Access date/time fields store points in time encoded as real numbers.
The integer part of the number is the number of days (day 1 was 31
December 1899, the reason why is too embarrasing to recount); the
fractional part represents time of day (0.25 = 6 am; 0.5 = 12 noon and
so on).
If you put "6:00" in a date field, what gets stored is 0.25 - i.e. 06:00
on day 0, 30 December 1899. Most of the time, using ordinary addition
and subtraction on date/time values works OK, e.g. if
EndTime = 12:00 (0.5)
SetupTime = 6:00 (0.25)
Duration = EndTime - SetupTime
0.5 - 0.25 = 0.25
then CTime(0.25) gives the expected result of 06:00 (or the unexpected
result of 6:00 am, depending on the date/time formats you're using!).
There can be other snags, so in general it's safer to use the date/time
functions provided:
DateDiff() returns the difference between two date/time values in years,
days, hours, minutes or other units. That's what you need to use for the
present problem.
DateAdd() adds or subtracts a given number of days, hours (etc.) to or
from a date/time value.
On Wed, 31 May 2006 08:49:02 -0700, Beyuduzz
<Beyuduzz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I have a query that pulls the information below. I export it to excel to
create a graph, but the time fields are giving me problems. The duration
colum in access is formated at SHORT TIME. If it isn't, I get a decimal
number that doesn't make sense (see below). The other times are irrelevent
to the graph. I only care about the Room and duration. When imported into
excel, I want to Sum the duration column into a total number of hours.
MeetingDate | Room | SetupTime | StartTime | EndTime | Duration{hhmm}
5/19/2006 MDA 6:00 6:30 12:00 0.25
Here is what I have done so far to the duration field.
-- [endtime]-[setuptime]*60 this returns a medium time format
-- [endtime]-[setuptime]/60 this returns a medium time format
-- [endtime]-[setuptime]/24 this returns a medium time format
-- [endtime]-[setuptime]*24 this returns a crazy long date format
I want the duration column in a proper format that will SUM correctly when
exported to excel. Any help please.
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
.
- Prev by Date: Re: URGENT How use a weighing machine
- Next by Date: Re: code to link with a text file
- Previous by thread: Query by record number in access?
- Next by thread: Re: Time Format in Excel
- Index(es):
Relevant Pages
|