WEEK_ISO
The WEEK_ISO function returns an integer between 1 and 53 that represents the week of the year. The week starts with Monday. Week 1 is the first week of the year to contain a Thursday, which is equivalent to the first week containing January 4. Thus, it is possible to have up to 3 days at the beginning of the year appear as the last week of the previous year or to have up to 3 days at the end of a year appear as the first week of the next year.
- expression
- An expression that returns a value of one of the following built-in
data types: a date, a timestamp, a character string, or a graphic
string.
If expression is a character or graphic string, its value must be a valid string representation of a date or timestamp. For the valid formats of string representations of dates and timestamps, see String representations of datetime values.
The result of the function is a large integer. If the argument can be null, the result can be null; if the argument is null, the result is the null value.
Examples
- Using the PROJECT table, set the host variable WEEK (INTEGER)
to the week that project (‘AD2100') ended.
Results in WEEK being set to 5.SELECT WEEK_ISO(PRENDATE) INTO :WEEK FROM PROJECT WHERE PROJNO = 'AD3100'
- Assume that table X has a DATE column called DATE_1 with various
dates from the list below.
Results in the following:SELECT DATE_1, WEEK_ISO(DATE_1) FROM X
1997-12-28 52 1997-12-31 1 1998-01-01 1 1999-01-01 53 1999-01-04 1 1999-12-31 52 2000-01-01 52 2000-01-03 1