# week - script and chart function

This function returns an integer representing the week number according to ISO 8601. The week number is calculated from the date interpretation of the expression, according to the standard number interpretation.

Syntax:

week(timestamp [, first\_week\_day [, broken\_weeks [, reference\_day]]])

**Return data type:** integer

Arguments:

Week arguments

| Argument | Description |
| --- | --- |
| timestamp | The date to evaluate as a timestamp or expression resolving to a timestamp, to convert, for example '2012-10-12'. |
| first\_week\_day | Integer that defines which day to use as the first day of the week. By default,<br><br>QlikView functions use Monday as the first day of the week. The following values can be used:<br><br><ul> <li>0 (= Monday)    </li> <li>1 (= Tuesday)</li> <li>    2 (= Wednesday)    </li> <li>3 (= Thursday) </li> <li>   4 (= Friday)</li> <li>    5 (= Saturday)  </li> <li>  6 (= Sunday)</li> </ul> |
| broken\_weeks | The setting defines if weeks are broken or not.<br><br>By default<br>QlikView functions use unbroken weeks. This means that:<br><br><ul> <li>    In some years, week 1 starts in December, and in other years, week 52 or 53 continues into January.    </li> <li>Week 1 always has at least 4 days in January.</li> </ul><br><br>The alternative is to use broken weeks.<br><br><ul> <li>Week 52 or 53 do not continue into January.</li> <li>    Week 1 starts on January 1 and is, in most cases, not a full week.</li> </ul><br><br>The following values can be used:<br><br><ul> <li>0 (=use unbroken weeks)    </li> <li>1 (= use broken weeks)</li> </ul> |
| reference\_day | The setting defines which day in January to set as reference day to define week 1. By default, QlikView functions use 4 as the reference day. This means that week 1 must contain January 4, or put differently, that week 1 must always have at least 4 days in January.<br><br>The following values can be used to set a different reference day:<br><br><ul> <li>1 (= January 1)</li> <li>2 (= January 2)</li> <li>3 (= January 3)</li> <li>4 (= January 4)</li> <li>5 (= January 5)</li> <li>6 (= January 6)</li> <li>7 (= January 7)</li> </ul> |

Example 1:

`week ('2012-10-12')`

returns 41

Example 2:

`week(
 '35648')`

returns 32, because 35648 = 1997-08-06

Example 3:

`week('2012-10-12', 0, 1)`

returns 42