CURDATE()
Description
The CURDATE() function returns the current date as a value in YYYY-MM-DD format, depending on whether the function is used in string or numeric context.
Note
The difference from MySQL’s behavior is: curdate()+int returns the number of days from 1970-01-01. For example, curdate()+1 means the current date minus 1970-01-01 plus 1 day.
Syntax
1. > CURDATE()
Examples
1. mysql> SELECT CURDATE();
2. +------------+
3. | curdate() |
4. +------------+
5. | 2023-02-02 |
6. +------------+
7. 1 row in set (0.00 sec)
9. mysql> SELECT CURDATE() + 0;
10. +---------------+
11. | curdate() + 0 |
12. +---------------+
13. | 19390 |
14. +---------------+
15. 1 row in set (0.00 sec)
17. mysql> select cast(now() as date)=curdate() q;
18. +------+
19. | q |
20. +------+
21. | true |
22. +------+
23. 1 row in set (0.01 sec)
25. create table t1 (a int);
26. insert into t1 values (1),(2),(3);
28. mysql> select cast(now() as date)=curdate() q from t1;
29. +------+
30. | q |
31. +------+
32. | true |
33. | true |
34. | true |
35. +------+
36. 3 rows in set (0.01 sec)
