ZEOS-Tabel and Filter

Forum related to Firebird

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
Josef Koller
Junior Boarder
Junior Boarder
Posts: 26
Joined: 04.09.2005, 14:46

ZEOS-Tabel and Filter

Post 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
Michael
ZeosLib's Handyman :o)
ZeosLib's Handyman :o)
Posts: 189
Joined: 15.08.2005, 16:08
Location: Wehrheim
Contact:

Post 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:
  1. 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)
  2. DateTime values may be represented as strings using AnsiSQL format 'YYYY-MM-DD HH:MM:SS'
So please try something like this:

Code: Select all

'MyDateField < ''2004-01-01'''
:prog2: Use the source, dude!

[align=right]..::.. ZeosLib on SourceForge ..::..[/align]
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post 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 ;)
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
Michael
ZeosLib's Handyman :o)
ZeosLib's Handyman :o)
Posts: 189
Joined: 15.08.2005, 16:08
Location: Wehrheim
Contact:

Post by Michael »

@gto: :up:

I put your code into

Code: Select all

[syntax="delphi"]...[/syntax]
tags to enable Delphi syntax highlighting ;-)

P.S.: "sql" is also avilable :mrgreen: ... have a look!
:prog2: Use the source, dude!

[align=right]..::.. ZeosLib on SourceForge ..::..[/align]
Post Reply