Name

WEEK()

Synopsis

WEEK(date [, mode])

Returns the week number for date. If passed the optional mode parameter, the week number returned will be modified according to Table D-3. You can also use the function WEEKOFYEAR, which is equivalent to using the WEEK function with a mode of 3. This code returns the week number 14:

SELECT WEEK('2016-04-04', 1);
Table D-3. The modes supported by the WEEK function

Mode

First day of week

Range

Where week 1 is the first week ...

0

Sunday

0–53

with a Sunday in this year

1

Monday

0–53

with more than three days this year

2

Sunday

1–53

with a Sunday in this year

3

Monday

1–53

with more than three days this year

4

Sunday

0–53

with more than three days this year

5

Monday

0–53

with a Monday in this year

6

Sunday

1–53

with more than three days this year

7

Monday

1–53

with a Monday in this year

Get Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.