Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Elapsed Time Calcuation with DateDiff

Status
Not open for further replies.

Gigi0614

Programmer
Jun 20, 2004
25
0
0
US
I have a form with

TimeIN (short time)
TimeOUT (short time)

Elapsed Time ---> calculated field that is giving me trouble!!

I thought I could use the DateDiff function:

DateDiff ('h', [TimeIN], [TimeOUT])

But it's not working...

For example if somebody entered the following

TimeIN: 1:15 AM
TimeOUT: 2:00 AM

Elapsed time should equal 00:45

How can I get this to work??

Thanks!
 
Actually...

TimeIN & TimeOUT are defined as Medium Time,

ElapsedTime is defined as Short Time

 
Something like this ?
Format(TimeOUT-TimeIN, "hh:nn")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
How are ya Gigi0614 . . . . .

Try:

[blue]Format([TimeIn]-1-[TimeOut],"Short Time")[/blue]

Calvin.gif
See Ya! . . . . . .
 
How do you account for times great than 24 hours?

My statement here which works fine for up to 24 hours gives me an error OVER 24 Hours:

time(DateDiff("d",{reservation_request.rr_create_stamp},{reservation_request.rr_completestamp})-(if datepart("n",{reservation_request.rr_create_stamp}) < datepart("n",{reservation_request.rr_completestamp})+1 then 0 else 1),DateDiff("n",{reservation_request.rr_create_stamp},{reservation_request.rr_completestamp}) mod 60,00)

How do I Update to account for times > 24 ?

Thanks
 
Acutally Statement should read:

time(DateDiff("h",{reservation_request.rr_create_stamp},{reservation_request.rr_completestamp})-(if datepart("n",{reservation_request.rr_create_stamp}) < datepart("n",{reservation_request.rr_completestamp})+1 then 0 else 1),DateDiff("n",{reservation_request.rr_create_stamp},{reservation_request.rr_completestamp}) mod 60,00)



I changed the "d" back to "h"
 
Say that d=rr_completestamp - rr_create_stamp, then how about this ?
24*Int(d)+Format(d,"h") & Format(d,":nn")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top