Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Months_between

RE: Months_between

From: John Phan <johnphanz_at_hotmail.com>
Date: Mon, 16 Oct 2000 09:10:46 GMT
Message-Id: <10651.119295@fatcity.com>


Hi,
I agreed with Macro, but you see there are still some stranges. Section 1:

-months_between('28/02/2001','28/11/2000')=3
-months_between('28/02/2001','29/11/2000')=2.9677419
-months_between('28/02/2001','30/11/2000')=3
Section 2:
-months_between('28/02/2000','28/11/1999')=3
-months_between('28/02/2000','29/11/1999')=2.9677419
-months_between('28/02/2000','30/11/1999')=2.9354839
-months_between('29/02/2000','30/11/1999')=3

In fact, if we increase the begin day, for example, from 28/11/2000 to 30/11/2000, the months between begin day and end day should be decreased. Anyone can explain to me why?

Thanks,

John.

>From: "Rooy van, Marco" <Rooy_M_at_sfs.nl>
>To: "'johnphanz_at_hotmail.com'" <johnphanz_at_hotmail.com>
>Subject: RE: Months_between
>Date: Mon, 16 Oct 2000 09:07:04 +0200
>
>28/02/2001 and 30/11/2000 are both the last day of the month.
>28/02/2000 and 30/11/2000 are not both the last day of the month.
>The last day of february 2000 is 29/02/2000
>
>SQLWKS> select months_between('29/02/2000','30/11/1999') from dual;
>MONTHS_BET
>----------
> 3
>
>Best regards,
>
>Marco
>
>-----Oorspronkelijk bericht-----
>Van: John Phan [mailto:johnphanz_at_hotmail.com]
>Verzonden: maandag 16 oktober 2000 9:38
>Aan: Multiple recipients of list ORACLE-L
>Onderwerp: Months_between
>
>
>Hi,
>I've got some problems with my application. I have used "months_between"
>function of Oracle to calculate number of month between two days, but I
>really do not understand why the result is so strange.
>Could you explain to me what happend as follows:
>
>SQL> select months_between('28/02/2001','28/11/2000') from dual;
>
>MONTHS_BETWEEN('28/02/2001','28/11/2000')
>-----------------------------------------
> 3
>
>SQL> select months_between('28/02/2001','29/11/2000') from dual;
>
>MONTHS_BETWEEN('28/02/2001','29/11/2000')
>-----------------------------------------
> 2.9677419
>
>SQL>select months_between('28/02/2001','30/11/2000') from dual;
>
>MONTHS_BETWEEN('28/02/2001','30/11/2000')
>-----------------------------------------
> 3
>
>SQL>select months_between('28/02/2000','28/11/1999') from dual;
>
>MONTHS_BETWEEN('28/02/2000','28/11/1999')
>-----------------------------------------
> 3
>
>SQL>select months_between('28/02/2000','29/11/1999') from dual;
>
>MONTHS_BETWEEN('28/02/2000','29/11/1999')
>-----------------------------------------
> 2.9677419
>
>SQL>select months_between('28/02/2000','30/11/1999') from dual;
>
>MONTHS_BETWEEN('28/02/2000','30/11/1999')
>-----------------------------------------
> 2.9354839
>
>Thanks for your help,
>
>John.
>_________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>Share information about yourself, create your own public profile at
>http://profiles.msn.com.
>
>--
>Please see the official ORACLE-L FAQ: http://www.orafaq.com
>--
>Author: John Phan
> INET: johnphanz_at_hotmail.com
>
>Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
>San Diego, California -- Public Internet access / Mailing Lists
>--------------------------------------------------------------------
>To REMOVE yourself from this mailing list, send an E-Mail message
>to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
>the message BODY, include a line containing: UNSUB ORACLE-L
>(or the name of mailing list you want to be removed from). You may
>also send the HELP command for other information (like subscribing).



Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Received on Mon Oct 16 2000 - 04:10:46 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US