Hello,
I use ZTable and ZConnection to a Firebird DB. And I would like to get a filter like this:
ztable1.filter:='Buchungsdatum ='+quotedstr(dateedit1.text);
dateedit1.text is for example :'01.01.05'
But it not works. Every other filter without a date works fine.
What have I to do to get a filter-string to a date field?
Best regards
Josef
ZEOS-Tabel and Filter
Moderators: gto, cipto_kh, EgonHugeist
Hi, Josef!
The Filter expression calculator supports implicit comvertions between many data types including (Boolean, Integer, Float, DateTime, String).
For Date/DateTime values there are two ways to compare date-time values:
The Filter expression calculator supports implicit comvertions between many data types including (Boolean, Integer, Float, DateTime, String).
For Date/DateTime values there are two ways to compare date-time values:
- As you know TDateTime type is defined as Double in Delphi. You may use that fact to represent a date in the expression like:
'MyDateField < 124345.4566', where float value is defined like Double(MyDateTimeVar) - DateTime values may be represented as strings using AnsiSQL format 'YYYY-MM-DD HH:MM:SS'
Code: Select all
'MyDateField < ''2004-01-01'''
Yep!
I've got problems with filters too, so there's my little function to convert a date in format "dd/mm/yyyy" to "yyyy-mm-dd":
[syntax="delphi"]
function FilterDate(Data: string): string;
var
Dia, Mes, Ano: string;
begin
Dia := copy(Data, 1, 2);
Mes := copy(Data, 4, 2);
Ano := copy(Data, 7, 4);
Result := quotedstr(ano + '-' + Mes + '-' + Dia);
end;
[/syntax]
Note that direct passing a TDateTime variable will mess the things up.. consider use FormatDateTime
I've got problems with filters too, so there's my little function to convert a date in format "dd/mm/yyyy" to "yyyy-mm-dd":
[syntax="delphi"]
function FilterDate(Data: string): string;
var
Dia, Mes, Ano: string;
begin
Dia := copy(Data, 1, 2);
Mes := copy(Data, 4, 2);
Ano := copy(Data, 7, 4);
Result := quotedstr(ano + '-' + Mes + '-' + Dia);
end;
[/syntax]
Note that direct passing a TDateTime variable will mess the things up.. consider use FormatDateTime
@gto:
I put your code into
tags to enable Delphi syntax highlighting
P.S.: "sql" is also avilable ... have a look!
I put your code into
Code: Select all
[syntax="delphi"]...[/syntax]
P.S.: "sql" is also avilable ... have a look!