Subject Comparing Time portion of Date in query
Author surf_n_golf
Does anyone know how to compare only the Time portion of a Date
field? If just run query "Select * from MyTable where Time1 < Time2"
then will rely on both Date and Time (so if Time1 has date of
1/1/2003 and Time2 has date of 1/1/2005 then will think Time1 is
less than Time2, regardless of the Time portion of date).

Only way I could think of to do this was to convert the time to a
string and then compare. Tried the following but both failed:

1) Cast to a char - but dont know how to get just Time part.
The "Cast(Time1, char(20))" will give me something like "01-JAN-2003
14:04:06". This would work if could just get last 8 chars. I tried
to use SubStr, but interbase did not recognize this keyword.

2) Extract individual parts - problem with leading zeros though.
If use "Extract(hour from Time1) || Extract(minute from Time1) etc."
then will get something like "1446.0000". I dont mind the extra
zeros after the decimal, but cant compare strings unless all single
digit values are left padded with zeros (like 120406.0000).

So, if anyone knows how to get either 1 or 2 to work, or if they
know a better way to compare time-only portion of date fields, then
please let me know.

Thanks!