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)
  8. mysql> SELECT CURDATE() + 0;
  9. +---------------+
  10. | curdate() + 0 |
  11. +---------------+
  12. | 19390 |
  13. +---------------+
  14. 1 row in set (0.00 sec)
  15. mysql> select cast(now() as date)=curdate() q;
  16. +------+
  17. | q |
  18. +------+
  19. | true |
  20. +------+
  21. 1 row in set (0.01 sec)
  22. create table t1 (a int);
  23. insert into t1 values (1),(2),(3);
  24. mysql> select cast(now() as date)=curdate() q from t1;
  25. +------+
  26. | q |
  27. +------+
  28. | true |
  29. | true |
  30. | true |
  31. +------+
  32. 3 rows in set (0.01 sec)