Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 02-16-2001, 03:11 AM
larshgf larshgf is offline
Senior Member
 
Join Date: Jan 2001
Posts: 237
Default SQL-problem

Hi!

I got a Query (called Doctors) with a column (called Christmas) holding som Year's data (i.e. 1998, 2000, 2001 etc).
I would like to be able to filter those posts that have this year between to defined years (ex 1992 nad 1998)
What I have tried is this......

Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('SELECT * FROM '+Doctors);
Query1.SQL.Add('WHERE Christmas BETWEEN 1992 AND 1998');
Query1.Open;

This one gives an error message saying 'Type mismatch in expression'.

Does anyone have a solution?

Thanks a lot
Lars, Denmark
Reply With Quote
  #2  
Old 02-16-2001, 03:39 AM
digitiger digitiger is offline
Senior Member
 
Join Date: Jan 2001
Posts: 716
Default RE: SQL-problem

first check that the christmas field is numeric and not a varchar2/string/date type as that is the most possible reason for this type of message

if that is not so and u are sure that the field is of numeric type then

just in last line change your string as follow and retry

Query1.SQL.Add('WHERE Christmas BETWEEN (1992 AND 1998)');
Reply With Quote
  #3  
Old 02-16-2001, 04:29 AM
larshgf larshgf is offline
Senior Member
 
Join Date: Jan 2001
Posts: 237
Default RE: RE: SQL-problem

Thanks for the quick answer!
But Is it not possible to do the trick with the years in plain stringvariables like '1998' and '2001'?

Lars
Reply With Quote
  #4  
Old 02-16-2001, 08:35 AM
jos jos is offline
Junior Member
 
Join Date: Feb 2001
Posts: 5
Default RE: SQL-problem

hi :-)

if Christmas is character type, try this.

Query1.SQL.Add('WHERE (Christmas >= "1992") AND (Christmas >= "1998")');

I already try it and it work
jos
Reply With Quote
  #5  
Old 02-16-2001, 08:38 AM
jos jos is offline
Junior Member
 
Join Date: Feb 2001
Posts: 5
Default RE: SQL-problem

hi again :-)

the other post has han error, here's the correct one.

Query1.SQL.Add('WHERE (Christmas >= "1992") AND (Christmas <= "1998")');


jos
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 07:14 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.