isoweek(X)

Returns the ISO-8601 week-numbering week for a given date or timestamp. (Available as of version 16.04)

Syntax

isoweek(X)

Input

Argument Type Description
X integer or decimal A scalar value or the name of a column containing date-related values
Valid values can be of the form:
  • date
  • month
  • quarter
  • date+time

For more information, see Dates and time .

Return Value

Returns the integer value (e.g., 1=first week of the year, 52=last week of the year) corresponding to the day of the week based on the input.

If the input values are not in one of the supported formats listed above, the function returns an erroneous or illogical output.

Example

Applying this function to a date column in a table will calculate the week number for each row. Note that in this example screenshot, it has acted on the last day of the year, but since the week where that day fell also contained the new year, the week value is 1:

<base table="retaildemo.retail.sales_detail"/>
<willbe name="isoweek" value="isoweek(date)"/>
<colord cols="date,isoweek"/>

Example

Applying this function to a scalar value which represents a date will simply return the week number for that date. Notice here the date falls within the last full calendar week of the year, so isoweek returns 52.

<base table="retaildemo.retail.sales_detail"/>
<willbe name="isoweek" value="isoweek(20121229)"/>
<colord cols="isoweek"/>