Problem With Date Format in MySQL 4.0.x?

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
kendiboy
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 20.07.2007, 17:23
Contact:

Problem With Date Format in MySQL 4.0.x?

Post 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:
pol
Senior Boarder
Senior Boarder
Posts: 91
Joined: 13.10.2005, 08:19

Post 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
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post 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!
Post Reply