SELECT WEEK('2023-01-02'); # 1
SELECT WEEK('2023-12-31'); # 53
SELECT WEEK('2026-08-31'); # 35
SELECT WEEK('2026-02-31'); # ull
SELECT WEEK('2024-01-01',0); # 0
SELECT WEEK('2024-01-01',1); # 1
SELECT CURDATE() dt1, WEEK(CURDATE()) dt2
Output is 2026-09-09 36
WEEK(date,[mode])
Example
SELECT WEEK('2015-07-25')
Output is 29
SELECT WEEK('2015-02-31')
Output is NULL
| Mode | First day of week | Range | Week 1 is the first week … |
|---|---|---|---|
| 0 | Sunday | 0-53 | with a Sunday in this year |
| 1 | Monday | 0-53 | with 4 or more days this year |
| 2 | Sunday | 1-53 | with a Sunday in this year |
| 3 | Monday | 1-53 | with 4 or more days this year |
| 4 | Sunday | 0-53 | with 4 or more days this year |
| 5 | Monday | 0-53 | with a Monday in this year |
| 6 | Sunday | 1-53 | with 4 or more days this year |
| 7 | Monday | 1-53 | with a Monday in this year |
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.