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.

Read syntax diagram
>>-WEEK_ISO(expression)----------------------------------------><

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.

Start of changeIf 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.End of change

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.

Example 1: Using sample table DSN8A10.PROJ, set the integer host variable WEEKISO to the week of the year that project 'AD2100' ended.
   SELECT WEEK_ISO(PRENDATE)
     INTO :WEEKISO
     FROM DSN8A10.PROJ
     WHERE PROJNO = 'AD2100';
Example 2: The following list shows what is returned by the WEEK_ISO function for various dates.
   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 
Start of changeExample 3: The following invocations of the WEEK_ISO function returns the same result:
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.End of change

Start of changeWhen 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' .End of change