Subtract time fields in Access -


i have table in access 2013 follow daily attendance @ work. in day, people need work 8 hours. here screenshot of table: enter image description here

column total = time until - time , ok.

column missing has = 8-format(24*int([total])+hour([total]);"0") & ":" & format([total];"nn")

the problem in missing column. if in total column says person did 7 hours, in missing column need 1 hours (1 hour missing complete 8 hours daily work)

notice second , last rows ... reason doesn't calculate correctly...

when there 30 mins... doesnt calculate right... in last row, should 1:30 missing (to complete 8 h in day)

how calculate it?

date/time values double-precision float numbers. means can math directly on them. in results query, computed values may displayed double-precision float ... can use format() present them in desired time format.

i tested query sample data in access 2010. returns results think want.

select     t.[time from],     t.[time until],     format((t.[time until] - t.[time from]), 'h:nn') [total],     format(#08:00# - (t.[time until] - t.[time from]), 'h:nn') [missing] tblvolkan t; 

for case [total] greater 8 hours, perhaps may prefer display [missing] negative value. if so, substitute expression ...

iif(#08:00# - (t.[time until] - t.[time from]) < 0, '-', '')     & format(#08:00# - (t.[time until] - t.[time from]), 'h:nn') [missing] 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -