CURDATE()¶
Function Description¶
The CURDATE() function returns the value in the YYY-MM-DD format of the current date.
Note
Unlike MySQL behavior: curdate()+int represents the total number of days from the current date to 1970-01-01 plus int (days). For example, curdate()+1 means the current date minus 1970-01-01 plus 1 day.
Function Syntax¶
Text
> CURDATE()
Example¶
Text
mysql> SELECT CURDATE();
+------------+
| curdate() |
+------------+
| 2023-02-02 |
+------------+
1 row in set (0.00 sec)
mysql> SELECT CURDATE() + 0;
+---------------+
| curdate() + 0 |
+---------------+
| 19390 |
+---------------+
1 row in set (0.00 sec)
mysql> select cast(now() as date)=curdate() q;
+------+
| q |
+------+
| true |
+------+
1 row in set (0.01 sec)
create table t1 (a int);
insert into t1 values (1),(2),(3);
mysql> select cast(now() as date)=curdate() q from t1;
+------+
| q |
+------+
| true |
| true |
| true |
+------+
3 rows in set (0.01 sec)
Last updated on