Previous Topic

Next Topic

Book Contents

Book Index

%%$YEARWK#

The %%$YEARWK# function calculates in which week of the year (1 through 53) a specified date falls, and returns the year and the week number according to ISO8601 standards. In accordance with those standards, the function uses Monday as the first day of each week (this is so even if the start of the week at your site is defined as Sunday).

The %%$YEARWK# function assumes that the first week is the week that includes January 4th

This function ensures that the first week in the year has a majority of its days in January. However, it also means that the first days of the year may possibly belong to the last week of the preceding year, and the last days of the year may possibly belong to the first week of the following year.

By contrast, the %%$WEEK# AutoEdit function, which also calculates in which week of a year a date falls, counts the week that includes January 1st as the first week. This ensures that every day of the year is part of a week of that year. However, it also means that the first week of the year may possibly have a majority of its days in December of the preceding year.

The format of the %%$YEARWK# function is:

%%$YEARWK# date

where date is the date in format yyyymmdd (a 4-character year must be specified).

The value returned by the function is in the format:

yyyyWnn

where:

Example 1

//* %%SET %%A=%%$YEARWK# 20010214

%%A is assigned a value of 2001W06

Example 2

//* %%SET %%A=%%$YEARWK# 20050101

%%A is assigned a value of 2004W52

Example 3

//* %%SET %%A=%%$YEARWK# 20011231

%%A is assigned a value of 2002W01.

Parent Topic

Functions