Home

You are most welcome to share your knowledge with me, send your comments about this training.

SQL QUERIES

Tuesday, 6 January 2015

Month_between in Oracle


Months_between in Sql

The months_between function calculates the number of months between two dates. When the two dates have the same day component or are both last day of the month,then the return value is a whole number.

otherwise ,the return value includes a fraction that considers the differance in the days based on a day-month.

Syntax:-
The syntax for the oracle/PLSQL Months_between function is:-
Months_between(date1,date2)


Parameter or Arguments
Date1,Date2 are the dates used to calculate the number of Months.

If a fractional month is calculated,the Months_between function calculate the fraction based on a 31-day month.

Example :-
select MONTHS_BETWEEN (TO_DATE ('2014/12/20', 'yyyy/mm/dd'), TO_DATE ('2012/12/30', 'yyyy/mm/dd') ) from dual



Would Return :- 23.6774194

No comments:

Post a Comment