hours between time fields

G

Guest

what is the syntax for a calculated control that shows the hours passed
between two time fields. e.g start time, end time total elapsed hours= ?

ps the time fields are Medium time fields

tia
 
R

Rick Brandt

HB said:
what is the syntax for a calculated control that shows the hours
passed between two time fields. e.g start time, end time total
elapsed hours= ?

ps the time fields are Medium time fields

tia

The format is irrelevent. Use DateDiff(). You normally need to use the
increment one resolution higher than what you actually want because it counts
"boundaries crossed".

For example, DateDiff using days...

DateDiff("d", #1/1/05 12:59:59#, #1/2/2005 0:00:01#)

....yields 1 even though they are only one second apart.
 
S

Stephen Haley

Err why not subtract one date from the other and multiply by 24 to get
hours - you can always int() it if you want completed hours at least that
way you have control of the rounding. Dates are merely numbers representing
the number of days since 1/1/1900. If you are working with times of less
than 24hrs and your system runs a 24hr clock is a quick way of getting
elapsed time as well. Datediff is good for months & years which are
variable.

Stephen
 
G

Guest

SO, if time1 is 3:30 pm and time 2 is 5:00pm and I subtract and mult. * 24
I'll get 1.5? that is what I'm looking for. I tried the subtraction already
and got a decimal, wasnt sure what to mult. by.

If I'm mistaken, please clarify...

thanks.

H.B.
 
G

Guest

It worked, but created a problem. before I had a start and end time field I
just had an Hours worked field for each day of the week, and a weeekly total
fields that is a clacluated control that added up the hours fields. However,
now that the hours fields are calculated fields (end -start * 24) the total
field no longer adds them up? Any ideas why?
 

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