You need a single quote on both sides of the date.  What I think you are
actually doing is "Where data = 2/3/2009" (2 divided by 3 divided by 2009)
and you need it to be "Where data = '2/3/2009'.

Jerry 

-----Original Message-----
From: advanced_delphi@yahoogroups.com
[mailto:advanced_del...@yahoogroups.com] On Behalf Of pietro
Sent: Monday, March 02, 2009 3:06 PM
To: advanced_delphi@yahoogroups.com
Subject: [advanced_delphi] ADOQuery and date ??

Hello All,

here my situation:

- Delphi 7
- MS Access 2003  mdb
- One field is of type Date/Time  (actually I am interested only in date)

Writing to this field via the program is simple:
 
with ADOQuery2 do begin
        Open;
        insert;
        FieldByName('data').AsDateTime:=DP_data.time;      // this is a 
DateTimePicker
         Post;
        close;
end;

And finally I have my date like 02.03.2009 (dd.mm.yyyy) in the field. 
Database is happy ;-)

Now the big problem :

How to sort records based on the date ?

example:

    tData:= DBGrid2.DataSource.DataSet.fieldByName('data').AsDateTime;
    sData:= formatDateTime('dd/MM/yyyy',tData);

    with ADOQuery2 do begin
        if active then close;
        SQL.Clear;
        SQL.Add('SELECT * FROM tbl_log');
        SQL.Add('WHERE data = ' + sData);
        open;

this give no errors but returns no informations too !!!

After spending long time googling, please give me an advice !  thank you ,

Pietro



------------------------------------

Yahoo! Groups Links



Reply via email to