WEEK()

Description

Used to calculate the week number for a given date. This function returns an integer representing the week number of the specified date. If date is NULL, return NULL.

Syntax

  1. > WEEK(date)

Arguments

ArgumentsDescription
dateRequired. date represents the date to calculate the week number. MatrixOne defaults the start day of the week to Monday, and the return value ranges from 0 to 53.

Examples

  • Example 1:
  1. mysql> SELECT WEEK('2008-02-20');
  2. +------------------+
  3. | week(2008-02-20) |
  4. +------------------+
  5. | 8 |
  6. +------------------+
  7. 1 row in set (0.01 sec)
  • Example 2:
  1. drop table if exists t1;
  2. CREATE TABLE t1(c1 DATETIME NOT NULL);
  3. INSERT INTO t1 VALUES('2000-01-01');
  4. INSERT INTO t1 VALUES('1999-12-31');
  5. INSERT INTO t1 VALUES('2000-01-01');
  6. INSERT INTO t1 VALUES('2006-12-25');
  7. INSERT INTO t1 VALUES('2008-02-29');
  8. mysql> SELECT WEEK(c1) FROM t1;
  9. +----------+
  10. | week(c1) |
  11. +----------+
  12. | 52 |
  13. | 52 |
  14. | 52 |
  15. | 52 |
  16. | 9 |
  17. +----------+
  18. 5 rows in set (0.00 sec)

Constraints

The WEEK() function of MatrixOne only supports the date parameter, and does not support the optional parameter [, mode], which is different from MySQL.