total beginning and ending date

K

Karen

I have two fields named BegTime and EndTime that are using a default value of
time(). Then I have another field named TotalTime that I would like to have a
total of these two fields. Example 10:00 + 11:00 = 1.0. Does anyone know how
I could do this?

Thanks in advance.

Karen
 
J

John Vinson

I have two fields named BegTime and EndTime that are using a default value of
time(). Then I have another field named TotalTime that I would like to have a
total of these two fields. Example 10:00 + 11:00 = 1.0. Does anyone know how
I could do this?

I take it that you want the DIFFERENCE of the two times, not the total
- the time elapsed, no?

Take a look at the DateDiff() function. Your "TotalTime" field should
NOT exist in this table, or any other table; since it can be derived
from the BegTime and EndTime values, storing it would be redundant and
unwise. Instead, create a Query based on the table; select the BegTime
and EndTime fields, and in a vacant Field cell type

TotalTime: DateDiff("n", [BegTime], [EndTime]) / 60.

to calculate the time difference in minutes and then divide by 60 to
get fractional hours.

Note that this will not work over midnight; Time() is actually a
date/time value on December 30, 1899. If you'll ever want to span
midnight, you'ld do better to use Now() rather than Time() as the
default, to include both the date and the time.

John W. Vinson[MVP]
 
K

Karen

Thank you so much. That points me in the right direction. I had no idea how
to even begin.

John Vinson said:
I have two fields named BegTime and EndTime that are using a default value of
time(). Then I have another field named TotalTime that I would like to have a
total of these two fields. Example 10:00 + 11:00 = 1.0. Does anyone know how
I could do this?

I take it that you want the DIFFERENCE of the two times, not the total
- the time elapsed, no?

Take a look at the DateDiff() function. Your "TotalTime" field should
NOT exist in this table, or any other table; since it can be derived
from the BegTime and EndTime values, storing it would be redundant and
unwise. Instead, create a Query based on the table; select the BegTime
and EndTime fields, and in a vacant Field cell type

TotalTime: DateDiff("n", [BegTime], [EndTime]) / 60.

to calculate the time difference in minutes and then divide by 60 to
get fractional hours.

Note that this will not work over midnight; Time() is actually a
date/time value on December 30, 1899. If you'll ever want to span
midnight, you'ld do better to use Now() rather than Time() as the
default, to include both the date and the time.

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