Date/Time field dropping time value after .post

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
sbsllc
Posts: 2
Joined: Sat 06 Feb 2016 19:42

Date/Time field dropping time value after .post

Post by sbsllc » Sat 06 Feb 2016 20:07

Hi All,

I am using version 8.6.21 along with Delphi XE3.
When I post a value to a date/time field the time value seems to drop off.

The code looks something like this:
mysqlqry.Append;
mysqlqry.FieldByName('datefield').AsDateTime := Now;
mysqlqry.Post;

So right before the post the value in mysqlqry.FieldByName('datefield').AsDateTime is 2/6/2016 2:06:19 PM but right after posting it 2/6/2016.

Thanks

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Date/Time field dropping time value after .post

Post by ViktorV » Fri 12 Feb 2016 14:14

The DATE server type allows to store only date, TIME - only time. Therefore, on execution of your code, the DATE field will store only current date. To store a date-time value, you should use the DATETIME or TIMESTAMP server types.

sbsllc
Posts: 2
Joined: Sat 06 Feb 2016 19:42

Re: Date/Time field dropping time value after .post

Post by sbsllc » Sat 13 Feb 2016 02:09

The server field type is DATETIME.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Date/Time field dropping time value after .post

Post by ViktorV » Mon 15 Feb 2016 14:13

Unfortunately, we couldn't reproduce the issue: when executing your code, correct data and time were saved to a DATETIME field. To investigate the issue, please compose a small sample demonstrating the described behavior and send it to us, including scripts for creating database objects.

Post Reply