Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Months_Between flaw?
I believe that there is a flaw with the Months_Between function.
There are times where I need to select transactions that have occured within
the past month (calendar). I was using something akin to:
select sum(amount) from transactions
where trunc(months_between(today, processed))=0;
During testing I found that it would include invalid data.
The error occurs when today = '28-Feb-99'. Transactions on '1/31/99' will not
be included, however, events on 1/29 and 1/30 will.
I have since avoided this issue by the using the following:
select sum(amount) from transactions
where to_char(processed, 'MM/yyyy') = to_char(today, 'MM/yyyy');
Comments?
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Fri Apr 02 1999 - 18:34:15 CST
![]() |
![]() |