Subject Re: [firebird-support] SQL Time field help
Author Bogusław Brandys
Helen Borrie wrote:
> At 02:47 PM 23/06/2005 -0500, you wrote:
>
>><<Thry this:
>>
>>
>>>update scheduled_work
>>>
>>>set shift_begin = Cast('07:00:00' AS TIME),
>>>
>>>shift_end = cast('15:00:00' as time)
>>>
>>>where shiftcd in (1,4,7,10)
>>
>>Beauty (that worked a t[h]reat)!
>
>
> The casting is superfluous, since the engine supports the time literal
> directly - as long as you use the 'hh:nn:ss' or 'hh:nn"ss.zzzz'
> format. Whatever you do to fudge Windows time strings, remember that the
> db engine works on the 24-hour clock.
>
> ./heLen
>

I have similiar problem. I have DATETIME column filled with data
imported from other source and time is always 00:00.

I have done comparison in SQl like

where DataSpr > '2005-01-06'



Should I change it to :

cast(DataSpr as DATE) > '2005-01-06' ?

What is I put parameter in that statement:


where DataSpr > :PARAM

and that parameter is TDateTime Delphi value ?


should I cast:

where Cast(DataSpr as DATE) > cast(:PARAM as DATE)

when doing grouping to avoid some time rounding problems ?


I have created compound index on DataSpr,Godzina,NrDok
(because DataSpr would have bad selectivity)

If I cast like above this index will be still used ?
Does this cast have some impact on query speed ?


Regards
Boguslaw