Here you go

Thursday, February 13, 2014

Oracle SQL to calculate Number of Days in a Year


Query Returns Number of Days in Year:


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 <= 2012
   );

No comments:

Post a Comment

Thanks for making a comment.