Board index » delphi » Date Lookup Help ?

Date Lookup Help ?

I am using the following to try and do a query based on matching dates ?
Not returning any data .. any ideas ?

sdate := datetostr(DateTimePicker1.Date);
edit1.text := sdate;

mysql := 'Select * from tb_appoint_info where date =' + sdate;
adoquery1.close;
adoquery1.SQL.text := mysql;
adoquery1.open;

 

Re:Date Lookup Help ?


Quote
> I am using the following to try and do a query based on matching dates ?
> Not returning any data .. any ideas ?

> sdate := datetostr(DateTimePicker1.Date);
> edit1.text := sdate;

> mysql := 'Select * from tb_appoint_info where date =' + sdate;
> adoquery1.close;
> adoquery1.SQL.text := mysql;
> adoquery1.open;

try this
mysql := 'Select * from tb_appoint_info where date =' +''''+ sdate+'''';
and  check the date format in the control panel  it must be MM/dd/aaaa well
it worked for me i'm using delphi 3

Re:Date Lookup Help ?


Quote
>I am using the following to try and do a query based on matching dates ?
>Not returning any data .. any ideas ?

try delimiting your date string with quotes

mysql := 'Select * from tb_appoint_info where date =' + quotedStr(sdate);
adoquery1.close;
adoquery1.SQL.text := mysql;
adoquery1.open;

Or if you are using Access you need to delimit date strings with # chracter
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads