Solved

datetime compare error

Posted on 2004-08-03
8
344 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 54
Convert a string into a TDateTime 5 61
How to load 2 images in same column in Delphi 2 47
MS Access from Delphi 31 32
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

803 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