WEEKOFYEAR()

Overview

Returns the calendar-week number for a date.

USAGE

WEEKOFYEAR(date)

Argument Name

Description

date

The date to evaluate

DETAILS

WEEKOFYEAR() is a date-time function that returns the week number in the range 1-53 for a given date.

The first day of the week is a Monday and first week of the year is one with 4 or more days in that year.

The return value is equivalent to calling WEEK(date, 3). See WEEK() for more details.

A NULL is returned if the argument is NULL.

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

EXAMPLES

SELECT WEEKOFYEAR('2020-02-01');
+--------------------------+
| WEEKOFYEAR('2020-02-01') |
+--------------------------+
|                        5 |
+--------------------------+
SELECT WEEKOFYEAR('2020-01-02');
+--------------------------+
| WEEKOFYEAR('2020-01-02') |
+--------------------------+
|                        1 |
+--------------------------+
CREATE TABLE day_list (
  d DATE
);
INSERT INTO day_list VALUES
  ('2028-01-01'), ('2028-01-02'), ('2028-01-03'),
  ('2028-12-30'), ('2028-12-31'), ('2029-01-01');
SELECT d AS 'date',
       DAYOFWEEK(d) AS DoW,
       WEEKOFYEAR(d),
       WEEK(d,3)
FROM day_list;
+------------+------+---------------+-----------+
| date       | DoW  | WEEKOFYEAR(d) | WEEK(d,3) |
+------------+------+---------------+-----------+
| 2028-01-01 |    7 |            52 |        52 |
| 2028-01-02 |    1 |            52 |        52 |
| 2028-01-03 |    2 |             1 |         1 |
| 2028-12-30 |    7 |            52 |        52 |
| 2028-12-31 |    1 |            52 |        52 |
| 2029-01-01 |    2 |             1 |         1 |
+------------+------+---------------+-----------+

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

23.09

  • Present starting in MariaDB Xpand 23.09.1.

6.1

  • Present starting in MariaDB Xpand 6.1.0.

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.1

  • Present starting in MariaDB Xpand 6.1.0.

EXTERNAL REFERENCES