DB2 Version 10.1 for Linux, UNIX, and Windows

MOD scalar function

Returns the remainder of the first argument divided by the second argument.

Read syntax diagramSkip visual syntax diagram
>>-MOD--(--expression1--,--expression2--)----------------------><

The schema is SYSIBM. (The SYSFUN version of this function continues to be available.)

expression1
An expression that returns a value of any built-in numeric data type.
expression2
An expression that returns a value of any built-in numeric data type. This expression can only be zero when at least one of the function arguments is a decimal floating point.
The formula for calculating the remainder is:
MOD(x,y) = x-(x/y)*y
where x/y is the truncated integer result of the division.

The result only is negative when the first argument is negative.

The result can be null if either argument can be null or if neither argument is a decimal floating-point number and the dft_sqlmathwarn database configuration parameter is set to YES; the result is the null value when either argument is NULL.

The data type of the result depends on the data types of the arguments.

Examples