Curriculum
Course: MYSQL
Login

Curriculum

MYSQL

MySQL References

0/140
Text lesson

WEEKOFYEAR

Example

Retrieve the week number corresponding to a specific date.

SELECT WEEKOFYEAR(“2017-06-15”);

Definition and Usage

The WEEKOFYEAR() function returns the week number (from 1 to 53) for a specified date.

Note: Assuming Monday is the first day of the week and the first week of the year has more than 3 days.

Tip: Also consider using the WEEK() function.

Syntax

WEEKOFYEAR(date)

Parameter Values

Parameter

Description

date

Required: The date or datetime from which to extract the week number.

Technical Details

Works in:

 From MySQL version 4.0

More Examples

Example

Retrieve the week number corresponding to a specific date.

SELECT WEEKOFYEAR(“2017-01-01”);

Example

Retrieve the week number for the current date according to the system’s configuration.

SELECT WEEKOFYEAR(CURDATE());