[MDEV-16358] select current_date, current_date + 1 giving wrong results Created: 2018-05-31  Updated: 2018-05-31  Resolved: 2018-05-31

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 10.0.29-galera
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Prakash Reddy Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
Labels: foundation

Attachments: JPEG File Mariadb_issue1.JPG    

 Description   

When i used the below statement

select current_date, current_date + 1
result is : 2018-05-31 20180532



 Comments   
Comment by Sergei Golubchik [ 2018-05-31 ]

This is correct. You want to use current_date + interval 1 day or adddate(current_date, 1) or date_add(), see the manual: https://mariadb.com/kb/en/library/date-time-functions/

What you do, you use the date in a numeric context, so the date is converted to a number, producing a number (not a date!) 20180531. And then you add 1 to that.

Comment by Alexander Barkov [ 2018-05-31 ]

We've just updated the documentation at https://mariadb.com/kb/en/library/type-conversion/ to make it more clear what happens on arithmetic operations.

Generated at Thu Feb 08 08:28:18 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.