The MOD and TO_NUMBER Functions

The MOD function is used to determine the modulus or remainder of a division operation. I have used it to calculate finish dates in scheduling applications. I divide the task hours by 40. Any remainder indicates that the task will be completed in less than a week. I use the MOD function to help me determine the portion (e.g., hours or days) of the week that the task will consume. I can then compute the finish date of the task. The function can be used in any other calculation in which the remainder is of value. Listing 7.1 illustrates a query that uses the function to determine whether a year is divisible by 4. This is a simple but not entirely accurate way to determine whether a year is a leap year.

The query ...

Get Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.