Date/Time Calculation

G

Guest

I have developed a Time Tracker in my query I have [Date Time Out] and [Date
Time In] appears like this
date time out date time in
2/19/2006 10:30:00 AM 2/20/2006 12:45:00 AM.

Under data type in my table I am using Date/Time with a format of General
Date.

I want this to be totaled in my [Hours] field, sometime will go after
midnight.

How can I get this to calculate the [Hours] in my query?
 
G

Grinder

Robb said:
I have developed a Time Tracker in my query I have [Date Time Out] and [Date
Time In] appears like this
date time out date time in
2/19/2006 10:30:00 AM 2/20/2006 12:45:00 AM.

Under data type in my table I am using Date/Time with a format of General
Date.

I want this to be totaled in my [Hours] field, sometime will go after
midnight.

How can I get this to calculate the [Hours] in my query?

Hours = 24 * (DateOut - DateIn)

DateTime types are just Doubles that count a number of days from a fixed
"zero date." So for example, if you have a date, and you want to add 6
hours, you can just add 0.25, or 1/4 of a day.
 
J

John Vinson

I have developed a Time Tracker in my query I have [Date Time Out] and [Date
Time In] appears like this
date time out date time in
2/19/2006 10:30:00 AM 2/20/2006 12:45:00 AM.

Under data type in my table I am using Date/Time with a format of General
Date.

I want this to be totaled in my [Hours] field, sometime will go after
midnight.

How can I get this to calculate the [Hours] in my query?

I'd suggest

DateDiff("h", [Date Time Out], [Date Time In])

to get integer hours; for hours and fractions of an hour, use

DateDiff("n", [Date Time Out], [Date Time In]) / 60

to calculate the time in miNutes ("m" is Months) and divide.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top