Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Quarters between dates?
JSchneider wrote:
> Dec 31 - Jan 2:
>
> SQL> select
> 2 months_between(
> 3 trunc(to_date('02-jan-00'),'Q'),
> 4 trunc(to_date('31-dec-99'),'Q')
> 5 )/3 + 1 SPAN_QUARTERS from dual;
>
> SPAN_QUARTERS
> -------------
> 2
oh, oops... better add an ABS() in there otherwise it gets confused when you put the smaller date first...
SQL> run
1 select
2 abs(months_between( 3 trunc(to_date('29-sep-99'),'Q'), 4 trunc(to_date('01-jan-00'),'Q')5* )/3) + 1 SPAN_QUARTERS from dual
SPAN_QUARTERS
3 Received on Tue Jun 14 2005 - 10:56:12 CDT
![]() |
![]() |