Solved How to use time from a field in which Date and Time both are written.

Local time
Today, 05:31
Joined
Aug 19, 2021
Messages
212
Hi, I am using the calculation data type field in my table to make a field that can calculate grace time for employee attendance.
There are 2 different fields Time_In and Time_Out. I want to use time from the Time_In field while both time and date are written in this field. Is there a way I can use only time from this field?

Following is the syntax that I am using to calculate grace time.
Code:
IIf([Time_In]>#9:00:00 AM# And [Time_In]<=#9:15:00 AM#,(Round(([Time_In]-#9:00:00 AM#)*24,2)),0)

You Can See the situation in the screenshots below.
1642137196840.png



1642137562739.png


Thank you in Advance.
 
Sorry, I did not notice trying this is table Calculated field. Use it in query or textbox.

If you want to compare just time parts, can't really include date part in parameter or need to concatenate 12/30/1899

CDate("12/30/1899 " & TimeValue([Time_In]))
 
you can also use TimeSerial():

IIf(TimeSerial(Hour([time_in]),Minute([time_in]),Second([time_in])) > #9:00:00# And TimeSerial(Hour([time_in]),Minute([time_in]),Second([time_in])) < #9:15:00#, Round((TimeSerial(Hour([time_in]),Minute([time_in]),Second([time_in])) - #9:00:00#_) * 24, 2) 0)
 
you can also use TimeSerial():

IIf(TimeSerial(Hour([time_in]),Minute([time_in]),Second([time_in])) > #9:00:00# And TimeSerial(Hour([time_in]),Minute([time_in]),Second([time_in])) < #9:15:00#, Round((TimeSerial(Hour([time_in]),Minute([time_in]),Second([time_in])) - #9:00:00#_) * 24, 2) 0)
Thank you so much arnelgp.
Solved
 

Users who are viewing this thread

Back
Top Bottom