Skip to content

WEEK

  • date: This parameter indicates the date value from which the week is to be extracted. It should be in a format accepted by MySQL, such as ‘YYYY-MM-DD’.
  • mode: This optional parameter determines how the function calculates the week number. For example, values range from 0 to 7, where each value specifies a different method of counting. If not provided, the default value is 0, which means the week starts on Sunday and week 1 is the first week with a Sunday in the current year.
SELECT WEEK('2022-03-01');
9

The WEEK() function in MySQL returns the week number for a given date. In the given example, ‘2022-03-01’ corresponds to the 9th week of the year.