Bug #79548 | In "Update t1 set b(date) = c(datetime)", micro seconds are rounded | ||
---|---|---|---|
Submitted: | 7 Dec 2015 15:12 | Modified: | 9 Dec 2015 19:42 |
Reporter: | Su Dylan | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
Version: | 5.7.8 | OS: | Any |
Assigned to: | Paul DuBois | CPU Architecture: | Any |
[7 Dec 2015 15:12]
Su Dylan
[7 Dec 2015 18:13]
MySQL Verification Team
Thank you for your report, but this is not a bug. Simply, datetime, timestamp accept time in milliseconds. DATE accepts only year, month and date. What you have observed in your report is that a datetime constant is fed into date column. In those cases, according to our manual and SQL standard, a conversion from datetime to date takes place. Hence, rounding is absolutely necessary. Not a bug.
[8 Dec 2015 3:09]
Su Dylan
Hi Sinisa, As the document says, when datetime values are coverted to date, the time part is discarded, not rounded as you mentioned. Please help to double check. Thanks. Quote ==== Conversion of DATETIME and TIMESTAMP values: Conversion to a DATE value discards the time part because the DATE type contains no time information. ==== https://dev.mysql.com/doc/refman/5.7/en/date-and-time-type-conversion.html
[8 Dec 2015 15:13]
MySQL Verification Team
Thank you for your report. It turns out that you are right !!!!! Our manual is wrong, so I am verifying this as a documentation bug. I have discovered, together with our developers, that code works correctly, while our manual is wrong. Fully verified as a documentation bug.
[9 Dec 2015 19:42]
Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly. A change in behavior occurred in MySQL 5.6.4 with the introduction of fractional-seconds support: Before MySQL 5.6.4, conversion to a DATE value discards the time part because the DATE type contains no time information. As of MySQL 5.6.4, fractional seconds are taken into account and conversion to DATE rounds the time part. For example, '1999-12-31 23:59:59.499' becomes '1999-12-31', whereas '1999-12-31 23:59:59.500' becomes '2000-01-01'.