Search By Time

TimTDP

Registered User.
Local time
Today, 14:50
Joined
Oct 24, 2008
Messages
213
I have the table "tblTempTrainingDateTime"
It contains the fields:
TrainingTimeId - AutoNumber
TrainingTime - Date/Time & Format = Short Time

I have a record where the TrainingTime = 10:00:00

Why does the following return a null value?
lngTrainingTimeId = DLookup("TrainingTimeId", "tblTempTrainingDateTime", "TrainingTime = #10:00:00#")

Thanks in advance
 
the field is not just time, it is date/time.

I usu put the table in a query, all fields, and add either date only or time only:
TimeOnly: Format([TrainingTime],"hh:nn:ss")

then youj can query only time:
= DLookup("TrainingTimeId", "qsTempTrainingDateTime", "TimeOnly= #10:00:00#")
 
Use the Time value function to compare just time?
 
the Format is for display purpose only.
it is still saving the Date portion (but not obvious).

lngTrainingTimeId = DLookup("TrainingTimeId", "tblTempTrainingDateTime", "TimeValue(TrainingTime) = #10:00:00#")
 
Thanks so much
Didn't know about function "TimeValue"

Thanks
 

Users who are viewing this thread

Back
Top Bottom