# `WEEK` — `WHILE...ENDWH`

## Contents

- `WEEK` — Gets the week in which a specified day falls
- `WHILE...ENDWH` — Conditional loop

## `WEEK` — Gets the week in which a specified day falls

Usage: `w%=WEEK(day%,month%,year%)`

Returns the week number in which the specified day falls, as an integer between 1 and 53.

`day%` must be between 1 and 31, `month%` between 1 and 12, `year%` between 0 and 9999.

Each week is taken to begin on the ‘Start of week’ day, as specified in the Control Panel. When a year begins on a different day to the start of the week, it counts as week 1 if there are four or more days before the next week starts.

The System setting of the ‘Start of week’ may be checked from inside OPL by using the `LCSTARTOFWEEK&`: procedure in the Date OPX. The week number in the year may also be calculated by different rules and also with your own choice of the start of year by using the procedure `DTWEEKNOINYEAR&`: in Date OPX.

See `Date.opx` — Date and time manipulation for more details.

## `WHILE...ENDWH` — Conditional loop

Usage:

        WHILE expression
              ...
        ENDWH

Repeatedly performs the set of instructions between the `WHILE` and the `ENDWH` statement, so long as expression returns true (non-zero).

If expression is not true, the program jumps to the line after the `ENDWH` statement.

Every `WHILE` must be closed with a matching `ENDWH`.

See also `DO`...`UNTIL` and Control structures.