Link to home
Start Free TrialLog in
Avatar of selas
selas

asked on

datetime compare error

On button click i get error near: where time > 2004.08.02 14NULL

procedure TForm8.RadioButton1Click(Sender: TObject); //ESANTYS
begin
RadioButton1.Checked := True;
AdoQuery1.SQL.Clear;
AdoQuery1.SQL.Add('Select id, time from esantys where time > 2004.08.02 14:00:00');
AdoQuery1.Open;
end;

How to make this work?
Avatar of geobul
geobul

Hi,

What database are you using?

Regards, Geo
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or better, let Borland do this with params

adoQuery1.SQL.add('Select id, time from esantys where time > :Param');
adoQuery1.paramByName('Param').AsDateTime := Date;

Edu
AdoQuery1.SQL.Add('Select id, time from esantys where time > ');
AdoQuery1.SQL.Add(QuotedStr(2004.08.02));

sorry I did not test, does it help ?
must be
AdoQuery1.SQL.Add(QuotedStr('your value here'));
like
AdoQuery1.SQL.Add(QuotedStr('2004.08.02')); or  ...
Avatar of kretzschmar
try the following format:

yyyy/mm/dd hh:mm:ss

meikl ;-)
i always do it this way:
'select * from timetable where time > ' + IntToStr(Trunc(My Date Variable here...))

that way you treat the date variable as a numeric value. always works for me! and i got the tip from this forum too
remove the trunc if you want time values in addition. not just the date value
like this:
FloatToStr(My Date Value)