Time difference

J

Jeremy Corson

I have a table that has a start time, end time, and call length. Whats the
best way to have access fill in the [call length] feild with the elapsed
time? The time will NEVER start on one day and end on another. Longest all i
have ever sense is about an hour.
 
J

Jeremy Corson

I also need directions on where i need to imput what ever you come up with...
im a newbie. The time format should be hh:mm or hhh:mm...hhhhhhhh:mm... you
get the point? lol
 
J

John Spencer

The best way - is not to do it. Normally, you don't store values that you can
calculate easily. Just calculate the duration when you need it in a query.

The simplest calculation is
CDate(EndTime - StartTime)

A better way might be to get the number of minutes or seconds using the DateDiff
function. To get the number of seconds use:

DateDiff("s",StartTime, EndTime)

Jeremy said:
I also need directions on where i need to imput what ever you come up with...
im a newbie. The time format should be hh:mm or hhh:mm...hhhhhhhh:mm... you
get the point? lol

Jeremy Corson said:
I have a table that has a start time, end time, and call length. Whats the
best way to have access fill in the [call length] feild with the elapsed
time? The time will NEVER start on one day and end on another. Longest all i
have ever sense is about an hour.
 
P

Peter R. Fletcher

Even easier (assuming that times never cross midnight) is simply

EndTime-StartTime

This gives you a floating point number containing the time difference
in _days_ (actually as a fraction of a day). Multiply by the
appropriate constant to get it into the units you want (e.g. 24 for
hours, 1440 for minutes....).

The best way - is not to do it. Normally, you don't store values that you can
calculate easily. Just calculate the duration when you need it in a query.

The simplest calculation is
CDate(EndTime - StartTime)

A better way might be to get the number of minutes or seconds using the DateDiff
function. To get the number of seconds use:

DateDiff("s",StartTime, EndTime)

Jeremy said:
I also need directions on where i need to imput what ever you come up with...
im a newbie. The time format should be hh:mm or hhh:mm...hhhhhhhh:mm... you
get the point? lol

Jeremy Corson said:
I have a table that has a start time, end time, and call length. Whats the
best way to have access fill in the [call length] feild with the elapsed
time? The time will NEVER start on one day and end on another. Longest all i
have ever sense is about an hour.

Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Top