Solved

datetime compare error

Posted on 2004-08-03
8
342 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
  • 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 500 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
 
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now