Oracle MOD
Introduction:
In this tutorial, we are going to explain how to use Oracle MOD function with basic syntax and many examples for better understanding.
MOD returns the remainder of number2 divided by number1. The modulus is calculated according to the formula: number2 – number1 * floor( number2 / number1 ).
Syntax:
MOD(number2,number1)
Name | Description |
number1 | The first argument to the function of number type. |
number2 | The second argument to the function of number type. |
Applies to::
Oracle 19c, Oracle 18c, Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i
Examples:
Let’s take some examples about Oracle MOD and how to use it:
Example (1)
SELECT MOD(32,9) FROM dual;
Example (2)
SELECT MOD(32,-9) FROM dual;
Example (3)
SELECT MOD(-32,9) FROM dual;
Example (4)
SELECT MOD(-32,-9) FROM dual;
Example (5)
SELECT MOD(9,32) FROM dual;
Example (6)
SELECT MOD(32,0) FROM dual;
Similar functions to Oracle MOD:
SUM : returns the sum of expression or columns.
ROUND : rounds the column, expression, or value to n decimal places.
GREATEST : returns the greatest value of given list of values.
LEAST : returns the smallest value of given list of values.
ABS : returns the absolute value of a number value passed to.
In this tutorial, you have learned how to use the MOD function to get the last day of the month on the date specified.
Hopefully, it was clear and concise.