Date Default values

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
NoComprende
Posts: 135
Joined: Tue 09 Jan 2007 13:44

Date Default values

Post by NoComprende » Sat 21 Apr 2007 13:31

If I give a NOT NULL DATE field a DEFAULT value of '9999-12-31' and assign it a NULL value in BCB6 it ends up with a value of '1899-12-30'.

I fare no better in the MySQL Query Browser as after assigning it a NULL value in that it ends up with a value of '0000-00-00'.

Anyone cast any light on this?

Using MySQL 5.0.27
MyDac 5.00.0.1

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

Post by Antaeus » Mon 23 Apr 2007 12:54

Try to use the Clear() method instead of assigning the NULL value:

Code: Select all

MyQuery1->FieldByName("Date_field")->Clear();

NoComprende
Posts: 135
Joined: Tue 09 Jan 2007 13:44

Post by NoComprende » Mon 23 Apr 2007 13:13

I tried that Antaeus but the result was the same.

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

Post by Antaeus » Mon 23 Apr 2007 14:58

I tested this issue withe following filed definition on the last MyDAC version (5.00.1.6):

Code: Select all

  `HIREDATE` date NOT NULL default '9999-12-31',
and the following code:

Code: Select all

  MyQuery1->Open();
  MyQuery1->Edit();
  MyQuery1->FieldByName("HireDate")->Clear();
  MyQuery1->Post();
I see in the server log that the following command is sent:

Code: Select all

  UPDATE emp
  SET
    HIREDATE = NULL
  WHERE
    EMPNO = 1 
Try to download the last MyDAC. I the problem persists, specify your code, and table definition.

Post Reply