MySQL WEEKOFYEAR() Function

In MySQL, the WEEKOFYEAR() function returns the week number in the current year for the gaven date. This function is equivalent to WEEK(date,3).

WEEKOFYEAR() Syntax

Here is the syntax of MySQL WEEKOFYEAR() function:

WEEKOFYEAR(date)

Parameters

date
Required. A date or datetime expression.

Return value

The MySQL WEEKOFYEAR() function returns the week number in the current year for the gaven date, in the range from 1 to 53.

The premise of this function is “the first day of the week is Monday and the first week of the year has more than 3 days”, which is equivalent to WEEK(date,3).

If the specified expression is not a valid date or datetime, the WEEKOFYEAR() function will return NULL.

If the argument is NULL, the WEEKOFYEAR() function will return NULL.

WEEKOFYEAR() Examples

Here are some examples of the WEEKOFYEAR() function.

SELECT
    WEEKOFYEAR('2022-01-01'),
    WEEKOFYEAR('2022-01-03');
+--------------------------+--------------------------+
| WEEKOFYEAR('2022-01-01') | WEEKOFYEAR('2022-01-03') |
+--------------------------+--------------------------+
|                       52 |                        1 |
+--------------------------+--------------------------+