Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

datetime compare error

Posted on 2004-08-03
8
Medium Priority
?
350 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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 you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
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

610 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