Page 1 of 1

Problem With Date Format in MySQL 4.0.x?

Posted: 20.07.2007, 17:35
by kendiboy
:?:
Dear any one,
I am new in direct my SQL programming using Delphi,
view days ago my friends send me ZEOS and now i'm use it,

But i have problem about date format, cause my local format is
dd/MM/yyyy and as we know mySQL format is ANSII format (yyyy-MM-dd).

i can't use this query
zquery.sql.add('SELECT * from xxxx where date_in between'+quotedstr(datetostr(datetimepicker1.date))+' AND '+quotedstr(datetostr(datetimepicker2.date))

the resulth is Always Empty table.

But when i change my regional setting to yyyy-MM-dd it's work;

Any one can't help me to solve my problem without changing my local time?

thank's a lot :shock:

Posted: 23.07.2007, 08:47
by pol
Why don't you use FormatDateTime('yyyy-MM-dd', datetimepicker1.date)? Then you can convert the date to any format you want.

Regards,
RĂ¼diger

Posted: 23.07.2007, 10:43
by mdaems
Have you tried using parameters?
I don't have Delphi here right now, but it should look something like :

qry.sql.text := '... between :datefrom and :dateto...'
qry.parameters.parambyname('datefrom').asdate := datetimepicker.value;
...
qry.open;

Have a look at Delphi doc of TQuery component concerning parameters. It should work that way.

The solution by pol certainly works as well. This is the easiest solution, which involves some format hardcoding, however.

Mark

Posted: 24.07.2007, 08:34
by zippo
.. or find some old Zeos 5.x and open the ZExtra.pas file - it's full of useful procedures.. :) Even with 6.x I'm still usingit!