This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-17. For the latest, interactive version please visit https://mariadb.com/kb/.

curdate operations error

MariaDB [(none)]> SELECT CURDATE() ;                                                                                                                                      
+------------+                                                                                                                                                            
| CURDATE()  |                                                                                                                                                            
+------------+                                                                                                                                                            
| 2019-03-04 |                                                                                                                                                            
+------------+                                                                                                                                                            
1 row in set (0.00 sec)                                                                                                                                                   
 MariaDB [(none)]> SELECT CURDATE() -2;
+--------------+
| CURDATE() -2 |
+--------------+
|     20190302 |
+--------------+
1 row in set (0.00 sec)
                                                                                                                                                                         
MariaDB [(none)]> SELECT CURDATE() -5;                                                                                                                                    
+--------------+                                                                                                                                                          
| CURDATE() -5 |                                                                                                                                                          
+--------------+                                                                                                                                                          
|     20190299 |                                                                                                                                                          
+--------------+                                                                                                                                                          
1 row in set (0.00 sec)

Answer Answered by Ian Gilfillan in this comment.

For date arithmetic, see DATE_ADD as well as CURDATE.

An example:

SELECT CURDATE();
+------------+
| CURDATE()  |
+------------+
| 2019-03-05 |
+------------+

SELECT CURDATE() - INTERVAL 5 DAY;
+----------------------------+
| CURDATE() - INTERVAL 5 DAY |
+----------------------------+
| 2019-02-28                 |
+----------------------------+
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.