Search notes:

Oracle: MONTHS_BETWEEN

months_between(dt_1, dt_2) calculates the (fractional) number of months between the two dates dt_1 and dt_2. The result is positive, if dt_2 is earlier than dt_1.
The following statement returns 42:
select
   months_between(
      add_months(sysdate, 42), -- The first parameter denotes a point in time after
                 sysdate       -- the point in time specified with the second parameter:
   )                           -- the result is positive.
from
   dual;

See also

add_months
In order to get whole numbers, the result might be passed to round(), ceil() or floor().
Other date related SQL functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759414054, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/SQL/functions/date/months_between(52): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78