[MDEV-20520] Adding +1 to a date give error Created: 2019-09-07 Updated: 2019-09-16 Resolved: 2019-09-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Temporal Types |
| Affects Version/s: | 10.3.15 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Akshat | Assignee: | Alexander Barkov |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 10 Home |
||
| Attachments: |
|
| Description |
|
I have a table with 2 date fields. update day19 set bdate = ddate+1 where narration like "th card%" I received the errors attached. It seems the date calculator gets stuck at month ends. Since there are no specific data files or error logs required I have not attached them. If required I can send them |
| Comments |
| Comment by Alexander Barkov [ 2019-09-12 ] | |||||||
|
ddate+1 treats ddate as a mumber, and the result of this expression is a number. It can produce values like 20190431 or 20190532 which cannot be translated back to DATE, hence the error. In order to do DATE arithmetic, please use this syntax with INTERVAL:
Notice, it correctly shifts to the next month. The ALTER query should be:
| |||||||
| Comment by Alexander Barkov [ 2019-09-16 ] | |||||||
|
Here's the relevant documentation: | |||||||
| Comment by Akshat [ 2019-09-16 ] | |||||||
|
Thank You for the conversion Links. It seems to be an error at first but now I see my error. Regards |