Time Calculation

J

Jeff

I have a "startTime" column and a "EndTime" Column. Is
there a way to create another column that automatically
calculates the duration between these times (in decimal
equiv.)? I also want to have a lookup list on this
column that has frequently used durations. When one of
the durations is picked it will override the EndTime.
 
J

jeff

-----Original Message-----
Create a query into this table.
Type a calculated field into a fresh column of the query design grid (Field
row) - something like this:
Minutes: DateDiff("n", [StartTime], [EndTime])

If you want hours and decimal, divide that by 60:
Hours: DateDiff("n", [StartTime], [EndTime]) / 60

IMHO, you should store either the duration or the end time, not both. You
can provide the interface for both, e.g. if you are storing Duration, you
could provide a text box to show the end time by setting its Control Source
to:
=DateAdd("n", [StartTime], [Duration])
and in its GotFocus event you could SetFocus to another text box (behind
this one) that has an AfterUpdate event procedure that updates the Duration
field with:
Me.Duration = DateDiff("n", Me.StartTime, Me.EndTime)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.


Jeff said:
I have a "startTime" column and a "EndTime" Column. Is
there a way to create another column that automatically
calculates the duration between these times (in decimal
equiv.)? I also want to have a lookup list on this
column that has frequently used durations. When one of
the durations is picked it will override the EndTime.


.
Allen,
thank you for your reply. Works great, Forgot about
datediff!!
 

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