Home > database >  Oracle months_between () function
Oracle months_between () function

Time:10-21

On June 30, on August 31 - why=2
On August 30 - June 30 also=2

CodePudding user response:

Number of days/30, is a decimal

CodePudding user response:

The function, combines add_months together to learn

For example,

Add_months (' 2019-02-28 ', 1)

Add_months (' 2019-02-27 ', 1)

CodePudding user response:

MONTHS_BETWEEN returns number of months between dates date1 and date2. The month and the last day of the month are defined by the parameter NLS_CALENDAR. If date1 is later than date2, then the result is positive. If date1 is earlier than date2, then the result is negative. If date1 and date2 are either the same days of the month or both last days of months, then the result is always an integer. Otherwise Oracle Database calculates the fractional portion of the result based on a 31-day month and considers the difference in time components date1 and date2.

CodePudding user response:

If date1 and date2 are either the same days of the month or both last days of up, then the result is always an integer.

CodePudding user response:

As well as the conclusion of the third floor, fourth floor after a few days, didn't quite understand!!!!! I looked at it again, only when date1 as the end of the month is the 30th will appear this kind of circumstance, to 31, the end of the date for the whole 30, 31 take 30 hours, according to the first parameter to this function to determine the date of calculation behind, don't know what to say, right? In the

CodePudding user response:

Days number or the same as the last day of each month, returns an integer, or based on 31, by number of days to calculate the decimal,
  • Related