Time Calculation

  • Thread starter Thread starter Jeff
  • Start date Start date
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.
 
-----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!!
 
Back
Top