Time difference

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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.
 
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
 

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

Back
Top