 |
|
Oracle months_between tips
Oracle Tips by Burleson Consulting |
This Oracle date function returns the months between
two dates. For example, if we wanted to know how many months an
employee has worked for the company, we can use this Oracle date function.
select
months_between(sysdate,emp_date_of_hire)
from
emp;
MONTHS_BETWEEN(SYSDATE,EMP_DATE_OF_HIRE)
----------------------------------------
58.7710805
70.7710805
34.7710805
Notice that this Oracle date function returns the
fraction of a month. You could use trunc or round to make the results
more readable.
 |
If you like Oracle tuning, see the book "Oracle
Tuning: The Definitive Reference", with 950 pages of tuning tips and
scripts.
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts. |