Problem With Date Format in MySQL 4.0.x?
Moderators: gto, cipto_kh, EgonHugeist
Problem With Date Format in MySQL 4.0.x?
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
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
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
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