Search code examples
sqlitedelphifiredac

DATETIME function not found when used in TFDTable.Filter expression


I'm using FireDAC with SQLite driver. (Delphi Tokyo 10.2.3)

Using DATETIME in a query expression works fine:

  with Query1 do
  begin
    Close;
    SQL.Text := 'select DATETIME(start_time) from times where ' +
      'DATETIME(start_time) >= DATETIME("2019-02-01 00:00:00")';
    Open;
    ....
  end;  

However, if I try to assign a similar expression to TFDTable.Filter:

tblTimes.Filter := 'DATETIME(start_time) >= DATETIME("2019-02-01 00:00:00")';
tblTimes.Filtered := True;

It results in this error:

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

Note: FireDAC.Stan.ExprFuncs is already in uses clause

What is wrong? Can such an expression be used in Filter clause (it worked fine for me using aducom components in D7)?


Solution

  • Try this:

    tblTimes.Filter := 'start_time >= {dt 2019-02-01 00:00:00}';
    tblTimes.Filtered := True;
    

    and please read this: http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Preprocessing_Command_Text_(FireDAC)