WEEKOFYEAR

Return the calendar week. This function returns the week number of the date (1-53), equivalent to WEEK(date, 3).

Syntax

WEEKOFYEAR(date)

Description

Returns the calendar week of the date as a number in the range from 1 sqto 53. WEEKOFYEAR() is a compatibility function that is equivalent to WEEK(date,3).

Examples

SELECT WEEKOFYEAR('2008-02-20');
+--------------------------+
| WEEKOFYEAR('2008-02-20') |
+--------------------------+
|                        8 |
+--------------------------+
CREATE TABLE t1 (d DATETIME);
INSERT INTO t1 VALUES
    ("2007-01-30 21:31:07"),
    ("1983-10-15 06:42:51"),
    ("2011-04-21 12:34:56"),
    ("2011-10-30 06:31:41"),
    ("2011-01-30 14:03:25"),
    ("2004-10-07 11:19:34");

This page is licensed: GPLv2, originally from fill_help_tables.sql

Last updated

Was this helpful?