I am working on a Attendance table in Access, where I have InTime
and OutTime
. These fields are of Date/Time Field.
Some records contains only Time like 11:40:00
, some contain Date as well as time like 21-07-2015 11:45:00
. Hence have used the below code for getting hours worked.
HrsPresent: Round(DateDiff("n",TimeValue(TimeSerial(Hour([TimeIn]),Minute([TimeIn]),Second([TimeIn]))),TimeValue(TimeSerial(Hour([TimeOut]),Minute([TimeOut]),Second([TimeOut]))))/60,2)
Using this above code, in a Column in making query gives correct Number of hours worked, but if any of the field is blank, i get #error
in result.
I have tried using Nz
, IsError
, IsNumeric
but all in Vain.
- What is it that, I am doing wrong?
- Is other way of getting hours worked?