Home > Expression Operators > Arithmetic Operators > #MOD

#MOD

Divides two numbers and returns the remainder (called the modulus).

Syntax:

divisor #MOD number

Examples:

10 #MOD 12 equals 2

100 #MOD 19890217 equals 17

(1000 #MOD RecID) = 0 is true for RecIDs 1000, 2000, 3000, etc.

(1000 #MOD RecID) = 42 is true for RecIDs 1042, 2042, 3042, etc.

The last two examples are an easy way to write a Selection Expression that selects every nth record. This could be helpful, for example, to test a cross-section of the population before executing a long-running job. Although #SUBSET could also be used for this purpose, this #MOD technique has the advantage that it does not have to be reset when closing and reopening ProVal.

See also:

#SUBSET