how to use Expresso / SQL Server Functions in a filter of a TFDQuery in delphi

0

I have the following situation, I need to check if the time of a certain task is not already filled in the system and for this by performing a SQL command in SQL Server 2014 works, as in the example

Select (cast((convert(datetime,hora,108)) +'00:01:00.000' as time(7))) as tempo from MIGRACOES_INTE_HORA

NOTE: I convert to transform time from Varchar to time ...

However in the system I use the filter property of a TFDQuery to perform the query, but to optimize it.

no filter add

(CAST((convert(datetime,'+TimeToStr(dtpInteHora.Time)+',108)) + '00:01:00.000', as time(7)) = '+DateToStr(qryInteHora.FieldByName('Hora').AsDateTime)+') or
(CAST((convert(datetime,'+TimeToStr(dtpInteHora.Time)+',108)) - '00:01:00.000', as time(7)) = '+DateToStr(qryInteHora.FieldByName('Hora').AsDateTime)+')

But when you activate the filter comes the following error

[FireDAC][Stan][Eval]-100. Column or function [CAST] is not found. Hint: if the name is a function name, then add FireDAC.Stan.ExprFuncs to uses clause.

Would anyone know how to do this filter?

    
asked by anonymous 04.01.2016 / 18:38

1 answer

1

Friend,

I searched here fast but could not get confirmation, however, I believe the TFDQuery Filter is applied only to the already loaded record of your DataSet. He does not apply this directly to your bank. Your queries are limited.

In your case, I believe you will have to apply the filter as a query for your query, so your bank is responsible for it.

    
08.01.2016 / 17:58