mod(X;Y)
Returns the modulo of two given values.
Syntax
mod(X;Y)
Input
Argument | Type | Description |
---|---|---|
X |
any numeric type | The dividend of the modulo operation |
Y |
any numeric type | The divisor of the modulo operation |
Return Value
Returns a numeric value corresponding to X
modulo Y
.
If both X
and Y
are integers, the result is an integer;
otherwise, the result is a decimal number.
If X
is N/A, the result is 0. If Y
is N/A, the result is
N/A. If X
and Y
are N/A, the result is N/A.
Sample Usage
X |
Y |
mod(X;Y) |
---|---|---|
13 | 10 | 3 (integer) |
9 | 3 | 0 (integer) |
5.0 | 2.5 | 0 (decimal) |
5 | 1.5 | 0.5 (decimal) |
NA | 1 | 0 (integer) |
1.0 | NA | NA (decimal) |
NA | NA | NA (integer) |
Example
In this example, the hour is displayed in 24-hour time (hour24only
) and
needs to be displayed as 12-hour time. The example uses the mod(X;Y)
function to return the 12-hour time, which is the result of hour24only
(X
) modulo 12
(Y
).
<base table="pub.doc.retail.salesdetail"/> <colord cols="transid, trans_date, tme"/> <willbe name="hour24only" value="hour(tme)"/> <willbe name="hour12mod" value="mod(hour24only;12)"/> <sel value="0.0001" sample="1"/>
Note:
<sel value="0.0001" sample="1"/>
selects a random sample of
1/10,000th of the data.