I have a dataset that I need to filter by time. e.g. I want records where the time contained in a TDateTime field is between 6:00 AM and 6:00 PM.
My dataset contains a field named time_of_day, of type TDateTime. The value assigned to the filed is a time, with no date.
I have tried creating the filter string using both the string representation of the time (time_of_day >= '6:00 AM' and time_of_day <= '6:00 PM'), and also using the floating point representation (time_of_day >= 0.25 and time_of_day < 0.75), but neither have worked.
I need to know how to construct the filter string to assign to the TDataSet.Filter property.
I think it might depend on short time format but this works for me using TADODataSet.
A more full proof solution is to use the OnFilterRecord event instead.
If you need interval it would look like this.
OnFilterRecord
If you use AMPM notation you need to enclose the time in
'But I would really recommend the OnFilterRecord instead so you do not have to worry about time formats.