select
trunc(input_date, 'YYYY') as the_year,
add_months(trunc(input_date, 'YYYY'), 12)
-
trunc(input_date, 'YYYY') as days_in_year
from
(
select
add_months(sysdate, -12 * level) as input_date
from dual
connect by level <= 20
12 );
THE_YEAR DAYS_IN_YEAR
-------------------- ------------
01-JAN-2009 12 00:00 365
01-JAN-2008 12 00:00 366
or
select to_date('01-JAN-'||to_char(to_number(to_char(sysdate,'YYYY'))+1),'DD-MM-YYYY')-trunc(sysdate,'YYYY') cnt
from dual
/
or
select add_months(trunc(sysdate,'YYYY'),12) -trunc(sysdate,'YYYY') cnt from dual
select
to_char(trunc(input_date, 'YYYY'), 'YYYY') as "Year",
add_months(trunc(input_date, 'YYYY'), 12)
-
trunc(input_date, 'YYYY') as days_in_year
from
(
select
add_months(sysdate, -12 * level) as input_date
from dual
connect by level <= 20
)
order by "Year" desc
;
Year DAYS_IN_YEAR
---- ------------
2009 365
2008 366
No comments:
Post a Comment