WEEK_ISO
The WEEK_ISO function returns an integer in the range of 1 to 53 that represents the week of the year. The week starts with Monday and includes seven days. Week 1 is the first week of the year that contains a Thursday, which is equivalent to the first week that contains January 4.
With the WEEK_ISO function, the first one, two, or three days in January might be included in the last week of the previous year. Likewise, the last one, two, or three days in December might be included in the first week of the next year.
The schema is SYSIBM.
The argument must be a date, a timestamp, or a valid string representation of a date or timestamp. A string representation must not be a CLOB or DBCLOB value and must have an actual length that is not greater than 255 bytes. For the valid formats of string representations of dates and timestamps, see String representations of datetime values.
If expression is a timestamp with a time zone, or a valid string representation of a timestamp with a time zone, the result is determined from the UTC representation of the datetime value.
The result of the function is a large integer.
The result can be null; if the argument is null, the result is the null value.
SELECT WEEK_ISO(PRENDATE)
INTO :WEEKISO
FROM DSN8A10.PROJ
WHERE PROJNO = 'AD2100';
DATE: WEEK_ISO returns:
---------------------------------
2003-12-28 52
2003-12-31 1
2004-01-01 1
2005-01-01 53
2005-01-04 1
2005-12-31 52
2006-01-01 52
2006-01-03 1
SELECT WEEK_ISO('1993-08-10-20.00.00'),
WEEK_ISO('1993-08-10-20.00.00-08:00'),
WEEK_ISO('1993-08-10-20.00.00+09:00')
FROM SYSIBM.SYSDUMMY1;
For each invocation of the WEEK_ISO
function in this SELECT statement, the result is 32.When the input argument contains a time zone, the result is determined from the UTC representation of the input value. The string representations of a timestamp with a time zone in the SELECT statement all have the same UTC representation: '1993-08-10-20.00.00' .