MOD Function

The MOD function takes as arguments two real number operands, and returns the remainder from integer division of the integer part of the first argument (the dividend) by the integer part of the second argument (the divisor). The value returned is an INT data type (or INT8 for remainders outside the range of INT). The quotient and any fractional part of the remainder are discarded. The divisor cannot be 0. Thus, MOD (x,y) returns y (modulo x). Make sure that any variable that receives the result is of a data type that can store the returned value.

This example tests to see if the current date is within a 30-day billing cycle:
SELECT MOD(TODAY - MDY(1,1,YEAR(TODAY)),30) FROM orders;