?
Solved

datetime compare error

Posted on 2004-08-03
8
Medium Priority
?
349 Views
Last Modified: 2010-04-05
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?
0
Comment
Question by:selas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 11701377
Hi,

What database are you using?

Regards, Geo
0
 
LVL 17

Accepted Solution

by:
geobul earned 2000 total points
ID: 11701405
Try quotation mark first:

AdoQuery1.SQL.Add('Select id, time from esantys where time > ' + QuotedStr('2004.08.02 14:00:00'));

If it's MS Access then:

AdoQuery1.SQL.Add('Select id, time from esantys where time > CDate("' + '2004.08.02 14:00:00'  + '")');

Regards, Geo
0
 
LVL 2

Expert Comment

by:DarkCore_
ID: 11701471
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:BdLm
ID: 11701486
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 ?
0
 
LVL 8

Expert Comment

by:BdLm
ID: 11701523
must be
AdoQuery1.SQL.Add(QuotedStr('your value here'));
like
AdoQuery1.SQL.Add(QuotedStr('2004.08.02')); or  ...
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 11701564
try the following format:

yyyy/mm/dd hh:mm:ss

meikl ;-)
0
 
LVL 5

Expert Comment

by:Darth_helge
ID: 11701810
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
0
 
LVL 5

Expert Comment

by:Darth_helge
ID: 11701891
remove the trunc if you want time values in addition. not just the date value
like this:
FloatToStr(My Date Value)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month8 days, 17 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question