Product Solutions Support
Try MemSQL

WEEK

Extracts the “week number” from the given datetime. There are eight ways to number weeks, described below.

WEEK ( dateobj, [mode] )
WEEKOFYEAR ( dateobj )

Arguments

Mode Description Counting from
0 Week (0 to 53) starting Sunday First week with a Sunday
1 Week (0 to 53) starting Monday First week with 4+ days
2 Week (1 to 53) starting Sunday First week with a Sunday
3 Week (1 to 53) starting Monday First week with 4+ days
4 Week (0 to 53) starting Sunday First week with 4+ days
5 Week (0 to 53) starting Monday First week with a Monday
6 Week (1 to 53) starting Sunday First week with 4+ days
7 Week (1 to 53) starting Monday First week with a Monday
Info

WEEKOFYEAR (date) is equivalent to WEEK(date, 3).

Return Type

Integer

Examples

memsql> select week('2009-02-13 23:31:30', 7);
+--------------------------------+
| week('2009-02-13 23:31:30', 7) |
+--------------------------------+
|                              6 |
+--------------------------------+
Was this article useful?