Week Functions
Get the day of the week or week number for a date. Use these functions to skip weekends in delivery estimates, group data by week, or build logic that depends on specific days.
Functions
WEEKDAY — Day of the week as a number
WEEKNUM — ISO week number (1-53)
WEEKDAY
Syntax: WEEKDAY(date, type)
Returns the day of the week as a number.
Parameters
date(Date or DateTime): The date to evaluatetype(Number, optional): Numbering system1(default): Sunday = 1, Monday = 2, ..., Saturday = 72: Monday = 1, Tuesday = 2, ..., Sunday = 7
Returns
Number from 1-7 representing the day of the week.
Examples
Check if it's a weekend:
WEEKDAY(CURRDATE()) = 1 OR WEEKDAY(CURRDATE()) = 7Skip weekends in delivery estimate:
ESTIMATED_DATE = ADDDAYS(ORDER_DATE, 5)
IF(WEEKDAY(ESTIMATED_DATE) = 1, ADDDAYS(ESTIMATED_DATE, 1),
IF(WEEKDAY(ESTIMATED_DATE) = 7, ADDDAYS(ESTIMATED_DATE, 2),
ESTIMATED_DATE))Weekend pricing:
IS_WEEKEND = WEEKDAY(EVENT_DATE) = 1 OR WEEKDAY(EVENT_DATE) = 7
IF(IS_WEEKEND, PRICE * 1.3, PRICE)Business day check (Monday-Friday):
WEEKDAY(DATE, 2) >= 1 AND WEEKDAY(DATE, 2)Display day name:
DAY_NUM = WEEKDAY(CURRDATE())
IF(DAY_NUM = 1, "Sunday",
IF(DAY_NUM = 2, "Monday",
IF(DAY_NUM = 3, "Tuesday", "...")))Use type 2 (Monday = 1) when building business day logic or working with ISO standards. Use type 1 (default) for weekend checks.
Type 1 (default): Sunday = 1. Type 2: Monday = 1. Choose based on your needs.
WEEKNUM
Syntax: WEEKNUM(date, type)
Returns the ISO week number of the year (1-53).
Parameters
date(Date or DateTime): The date to evaluatetype(Number, optional): Week start day1(default): Weeks start on Sunday2: Weeks start on Monday (ISO 8601 standard)
Returns
Number from 1-53 representing the week of the year.
Examples
Group orders by week:
WEEK_NUMBER = WEEKNUM(ORDER_DATE, 2)Weekly report label:
`Week ${WEEKNUM(CURRDATE(), 2)} - ${YEAR(CURRDATE())}`Check if same week:
WEEKNUM(DATE1, 2) = WEEKNUM(DATE2, 2) AND YEAR(DATE1) = YEAR(DATE2)Week-based billing period:
BILLING_WEEK = WEEKNUM(CURRDATE(), 2)
IF(BILLING_WEEK % 2 = 0, "Billing week", "Off week")ISO 8601 standard uses Monday as the first day of the week. Use type 2 for ISO compliance.
Some years have 53 weeks. Week 1 is the first week with 4+ days in the new year.
Common Patterns
Weekend check:
IS_WEEKEND = WEEKDAY(DATE) = 1 OR WEEKDAY(DATE) = 7
IF(IS_WEEKEND, "Closed", "Open")Business day validation:
IS_BUSINESS_DAY = WEEKDAY(DATE, 2)Adjust delivery for weekends:
DELIVERY = ADDDAYS(ORDER_DATE, 3)
ADJUSTED_DELIVERY =
IF(WEEKDAY(DELIVERY) = 1, ADDDAYS(DELIVERY, 1), // Sunday → Monday
IF(WEEKDAY(DELIVERY) = 7, ADDDAYS(DELIVERY, 2), // Saturday → Monday
DELIVERY))Week-over-week comparison:
CURRENT_WEEK = WEEKNUM(CURRDATE(), 2)
LAST_WEEK = WEEKNUM(ADDDAYS(CURRDATE(), -7), 2)Friday discount:
IF(WEEKDAY(CURRDATE()) = 6, PRICE * 0.9, PRICE)Common Mistakes
Forgetting type parameter affects numbering: Type 1: Sunday = 1. Type 2: Monday = 1. Default is type 1.
Comparing weeks across years: Week 1 of 2024 ≠ Week 1 of 2025. Always check YEAR() too.
Assuming Week 1 = January 1: Week 1 is the first week with 4+ days in January. Jan 1 might be Week 52 of the previous year.
Using WEEKDAY for business days without type 2: Use type 2 (Monday = 1) for easier Monday-Friday checks.
See Also
CURRDATE · DATE · DAY · MONTH · ADDDAYS · DATEDIFF