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
| Arguments | Description |
|---|---|
| date | Required. 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');
9. mysql> SELECT WEEK(c1) FROM t1;
10. +----------+
11. | week(c1) |
12. +----------+
13. | 52 |
14. | 52 |
15. | 52 |
16. | 52 |
17. | 9 |
18. +----------+
19. 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.
