Page 1 of 1
ZEOS-Tabel and Filter
Posted: 16.12.2005, 11:28
by Josef Koller
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
Posted: 16.12.2005, 13:08
by Michael
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:
- 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'
So please try something like this:
Posted: 16.12.2005, 21:46
by gto
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
Posted: 17.12.2005, 15:32
by Michael
@gto:
I put your code into
tags to enable Delphi syntax highlighting
P.S.: "sql" is also avilable
...
have a look!