QUARTERWEEK_ISO scalar function

Returns the week of the quarter that ADATE exists within (weeks start on a Monday, result will be in the range 1-6).

Prototypes

QUARTERWEEK_ISO(ADATE DATE)
QUARTERWEEK_ISO(ADATE TIMESTAMP)
QUARTERWEEK_ISO(ADATE VARCHAR(26))

RETURNS SMALLINT

Description

Returns the week of the quarter of ADATE, where weeks start on a Monday. The result will be in the range 1-14 as partial weeks are permitted. For example, if the first day of a month is a Sunday, it will be counted as week 1, which lasts one day. The next day, Monday, will start week 2.

Parameters

ADATE
The date to calculate the week of the quarter for.

Examples

Calculate the week of the quarter for 31st of January, 2010:

VALUES QUARTERWEEK_ISO(DATE(2010, 1, 31));
1
------
     5

Show the number of weeks in all quarters in the years 2007-2010:

SELECT YEAR(D) AS YEAR, QUARTER(D) AS QUARTER, QUARTERWEEK_ISO(QUARTEREND(D)) AS WEEKS
FROM TABLE(DATE_RANGE('2007-01-01', '2010-12-31', '300'));
YEAR        QUARTER     WEEKS
----------- ----------- ------
       2007           1     13
       2007           2     14
       2007           3     14
       2007           4     14
       2008           1     14
       2008           2     14
       2008           3     14
       2008           4     14
       2009           1     14
       2009           2     14
       2009           3     14
       2009           4     14
       2010           1     14
       2010           2     14
       2010           3     14
       2010           4     14