[MDEV-18159] Arithmatic operations on SYSDATE yields in-consistent results Created: 2019-01-07 Updated: 2019-01-23 Resolved: 2019-01-23 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Temporal Types |
| Affects Version/s: | 5.5, 10.0, 10.1, 10.2.14, 10.2, 10.3 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Kiran Kuppili | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
select DATE(SYSDATE()), DATE(DATE('2018-11-01')-1); select DATE(SYSDATE()), DATE(DATE('2018-11-30')+1); Both the cases should have returned NULL or yield expected dates as 2018-10-31 and 2018-12-01 respectively |
| Comments |
| Comment by Alice Sherepa [ 2019-01-07 ] | |||||||||||||||||||||||||||||||||
|
Thanks for the report!
| |||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2019-01-23 ] | |||||||||||||||||||||||||||||||||
|
This is not a bug. A DATE value in a numeric context is converted to a number. In your case, 20181101 and 20181130. After your arithmetic operations you get 20181100 and 20181131. The first can be converted back to a DATE (unless you set sql_mode to NO_ZERO_IN_DATES), the second cannot. For correct date arithmetic use DATE_ADD See: |