AsDAteTime makes 1 plus day

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
biasko
Posts: 6
Joined: Thu 05 Oct 2006 20:55

AsDAteTime makes 1 plus day

Post by biasko » Tue 14 Nov 2006 17:04

Hi!

My problem:
I hva sql sentence SELECT DATE(:d) AS DATE , field1 FROM table WHERE ....
ParamByName('d').AsDate:=info_date.Date; //info_date is calendar
if param= 2006-11-12 ...and my result is 2006-11-13
WHY?

then I put my paremeter like this
ParamByName('d').AsString:=FormatdateTime('YYYY-MM-DD',info_date.Date);
..works fine...but on some other computer I get message

you have an error in your MYSQL syntax. Check the amnual that coresponds...to use near '('2006-11-13') AS DATE, field1 FROM...'

thanks!

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 15 Nov 2006 11:09

Please send us (evgeniyD*crlab*com) a complete small sample to demonstrate the issue with the wrong date value, including script to create and fill table if it is required.
Also supply us following information
- Exact version of Delphi, C++ Builder or Kylix
- Exact version of MyDAC. You can see it in About sheet of TMyConnection Editor
- Exact version of MySQL server and MySQL client. You can see it in Info sheet of TMyConnection Editor

The error in the SQL syntax may be raised because of different date format used in different server instances. Try to check the date_format server variable.

biasko
Posts: 6
Joined: Thu 05 Oct 2006 20:55

Post by biasko » Wed 15 Nov 2006 14:24

i find out the problem but I still don't know way

it works!
ParamByName('d').AsDateTime:=info_date.Date;

now date is ok but in other computer still error
you have an error in your MYSQL syntax. Check the amnual that coresponds...to use near '('2006-11-13 11:21:22') AS DATE, field1 FROM...'

on the other computer is MYSQL 4x

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Thu 16 Nov 2006 15:55

Thank you for your collaboration. We have reproduced the problem. It happened because TMonthCalendar adds current time to the Date value. MyDac performed rounding but not truncating the time part of a TDateTime value to convert it to a TDate value. So the day became incremented. Now this problem is fixed. This fix will be included in the next MyDAC build.

Post Reply