Bug #15446 | Incorrect Date Formatting | ||
---|---|---|---|
Submitted: | 2 Dec 2005 20:37 | Modified: | 2 Dec 2005 20:45 |
Reporter: | Josh Parks | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 4.1.7 | OS: | Windows (Win XP) |
Assigned to: | CPU Architecture: | Any |
[2 Dec 2005 20:37]
Josh Parks
[2 Dec 2005 20:45]
Valeriy Kravchuk
Thank you for a problem report. Sorry, but the behaviour you described is known and intended. Use separate functions to get correct results: mysql> select curdate() - 1; +---------------+ | curdate() - 1 | +---------------+ | 20051201 | +---------------+ 1 row in set (0.00 sec) mysql> select curdate() - 2; +---------------+ | curdate() - 2 | +---------------+ | 20051200 | <--- wrong +---------------+ 1 row in set (0.00 sec) mysql> select date_sub(curdate(), interval 2 day); +-------------------------------------+ | date_sub(curdate(), interval 2 day) | +-------------------------------------+ | 2005-11-30 | <--- right! +-------------------------------------+ 1 row in set (0.01 sec) Read the manual, http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html, for the details.