WEEKEND scalar function¶
Returns the last day (always a Saturday) of the week that ADATE exists within, or the last day of the week AWEEK in the year AYEAR.
Prototypes¶
WEEKEND(AYEAR INTEGER, AWEEK INTEGER)
WEEKEND(ADATE DATE)
WEEKEND(ADATE TIMESTAMP)
WEEKEND(ADATE VARCHAR(26))
RETURNS DATE
Description¶
Returns a DATE representing the last day of AWEEK in AYEAR, or the last day of the week of ADATE (always a Saturday) depending on the variant of the function that is called.
Parameters¶
- AYEAR
- If provided, the year of AWEEK for which to return the ending date.
- AWEEK
- If provided, the week for which to return to the ending date.
- ADATE
- If provided the date in the week for which to return the ending date. Either AYEAR and AWEEK, or ADATE must be specified.
Examples¶
Calculate the ending date of the last week in 2010:
VALUES WEEKEND(2010, WEEKSINYEAR(2010));
1
----------
2011-01-01
Calculate the end of the week for the 28th of January, 2009:
VALUES WEEKEND('2009-01-28');
1
----------
2009-01-31
See Also¶
- Source code
- WEEKSTART scalar function
- WEEKEND_ISO scalar function
- WEEK (built-in function)