Subject comparing the TIME part of a DATE field
Author duilio_fos
I have shift start time and end time stored in 2 DATE fields of a
table, like:

CREATE TABLE Shifts
(
shift_id varchar(5) NOT NULL,
start_time date NOT NULL,
end_time date NOT NULL,
PRIMARY KEY (shift_id)
);


When I read the containt of - say - the START_TIME field, with

var
t:TDateTime;
begin
...
t:=FieldByName('start_time').AsDateTime;
...
end;

I can see that no integer part is stored in the field.

For instance, '20:00:00' is read as 0.83333...

The problem is:

I find no way to query via SQL all shifts whose start time is - say -
at or later than 20:00:00 .

If I write what I thought obvious

"select * from shifts where start_time>='0000-00-00 20.00.00'"

I get the error message "value exceeds the range for valid dates".

I can see that the field containt is displayed as

'30-12-99 20.00.00' in a TDBGrid.

However, writing

"select * from shifts where start_time>='1999-12-30 20.00.00'"

or

"select * from shifts where start_time>='2099-12-30 20.00.00'"

- while no error message is raised - gets an empty set, which is not
what I want, of course.

Any help ?

TIA

Duilio Foschi