midnight problem (24:00) calculation

hair

Registered User.
Local time
Today, 01:18
Joined
Mar 27, 2003
Messages
125
So, again I'm stocked with hours/

in my table I have a starthour and a finishhour. And in the form there is a calculated textbox that makes the difference = finishhour-starthour. Now, when the finishhour is midnight, no matter if I write it 00:00 or 24:00, the returned value from the calculation is wrong. How should I handle this? If I put 23:59 as finishhour makes a hole mess.

Thanks
 
If you can include the date as well as the time in the values for StartHour and FinishHour, you can use the DateDiff function to correctly calculate the time difference. Note that even if the date is included in the value, you can still display only the time portion of it by choosing an appropriate Format setting for the text box.
 
Thank You Alan

It gets quite complicated if I do that. I mean the person who put data inside has something like this:

Employee Client Date starthour endhour totalhours

(totalhours calculates itself)

And on a form I have a text which uses a query to make the total of hours. If I would follow your advice I should add a field named endhourdate or something. Which even if it's doable is not great cause let's say I have 4 records out of 100 with this particular situation. But it would be easy if this Acces would allow me to write 24 as an hour, so it would be clear this way. Im realy stocked in here.
 
Another approach is to simply check to see if the time difference is less than zero, and if so add 24 hours to it.
 
thats what I was looking for - this kind of solution
the thing is in a weird way, if I put starthour 23:30 and finish hour 00:00, it gives me the result 23:30. Without a minus. But the query that makes the total gives me minus. SO as I don't understand too much out of that, I was thinking that I could put a condition like 'if finhour is 00:00 than Total = totalhours+24

that might work but no obvious minus there. its because it's a time field?
 

Users who are viewing this thread

Back
Top Bottom