DAY()

Description

Returns the day of the month for date, in the range 1 to 31, or 0 for dates such as 0000-00-00 or 2008-00-00 that have a zero day part. Returns NULL if date is NULL.

Syntax

  1. > DAY(date)

Arguments

ArgumentsDescription
dateRequired. The date/datetime to extract the date from.

Examples

  1. mysql> SELECT day('2007-02-03');
  2. +-----------------+
  3. | day(2007-02-03) |
  4. +-----------------+
  5. | 3 |
  6. +-----------------+
  7. 1 row in set (0.01 sec)
  1. CREATE TABLE t3(c1 TIMESTAMP NOT NULL);
  2. INSERT INTO t3 VALUES('2000-01-01');
  3. INSERT INTO t3 VALUES('1999-12-31');
  4. INSERT INTO t3 VALUES('2000-01-01');
  5. INSERT INTO t3 VALUES('2006-12-25');
  6. INSERT INTO t3 VALUES('2008-02-29');
  7. mysql> SELECT day(c1) from t3;
  8. +---------+
  9. | day(c1) |
  10. +---------+
  11. | 1 |
  12. | 31 |
  13. | 1 |
  14. | 25 |
  15. | 29 |
  16. +---------+
  17. 5 rows in set (0.01 sec)