MySQL tutorial: WEEK [EN]
top of page
CerebroSQL

MySQL: 

WEEK

Syntax:
WEEK(date[,mode])

This function returns the week number for date. The two-argument form
of WEEK() enables you to specify whether the week starts on Sunday or
Monday and whether the return value should be in the range from 0 to 53
or from 1 to 53. If the mode argument is omitted, the value of the
default_week_format system variable is used. See
https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html.

URL: https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html

Example

mysql> SELECT WEEK('2008-02-20');
-> 7
mysql> SELECT WEEK('2008-02-20',0);
-> 7
mysql> SELECT WEEK('2008-02-20',1);
-> 8
mysql> SELECT WEEK('2008-12-31',1);
-> 53

bottom of page