WEEK

Return the week number. This function returns the week number for a date, with an optional mode to define the start of the week.

Syntax

WEEK(date[,mode])

Description

This function returns the week number for date. The two-argument form ofWEEK() allows you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to 53. If the mode argument is omitted, the value of the default_week_format system variable is used.

Modes

Mode
1st day of week
Range
Week 1 is the 1st week with

0

Sunday

0-53

a Sunday in this year

1

Monday

0-53

more than 3 days this year

2

Sunday

1-53

a Sunday in this year

3

Monday

1-53

more than 3 days this year

4

Sunday

0-53

more than 3 days this year

5

Monday

0-53

a Monday in this year

6

Sunday

1-53

more than 3 days this year

7

Monday

1-53

a Monday in this year

With the mode value of 3, which means 'more than 3 days this year', weeks are numbered according to ISO 8601:1988.

Examples

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

Last updated

Was this helpful?