For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.
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 01-JAN-2007 12 00:00 365 01-JAN-2006 12 00:00 365 01-JAN-2005 12 00:00 365 01-JAN-2004 12 00:00 366 01-JAN-2003 12 00:00 365 01-JAN-2002 12 00:00 365 01-JAN-2001 12 00:00 365 01-JAN-2000 12 00:00 366 01-JAN-1999 12 00:00 365 01-JAN-1998 12 00:00 365 01-JAN-1997 12 00:00 365 01-JAN-1996 12 00:00 366 01-JAN-1995 12 00:00 365 01-JAN-1994 12 00:00 365 01-JAN-1993 12 00:00 365 01-JAN-1992 12 00:00 366 01-JAN-1991 12 00:00 365 01-JAN-1990 12 00:00 365 20 rows selected. TUBBY_TUBBZ?
trunc(input_date, 'YYYY') as the_year, add_months(trunc(input_date, 'YYYY'), 12) - trunc(input_date, 'YYYY') as days_in_year
SQL> ed Wrote file afiedt.buf 1* select add_months(trunc(sysdate,'YYYY'),12) -trunc(sysdate,'YYYY') cnt from dual SQL> / CNT ---------- 365
select to_date('01-JAN-'||to_char(to_number(to_char(sysdate,'YYYY'))+1),'DD-MM-YYYY')-trunc(sysdate,'YYYY') cnt from dual / SQL> / CNT ---------- 365
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 2007 365 2006 365 2005 365 2004 366 2003 365 2002 365 2001 365 2000 366 1999 365 Year DAYS_IN_YEAR ---- ------------ 1998 365 1997 365 1996 366 1995 365 1994 365 1993 365 1992 366 1991 365 1990 365
select to_number(to_char(trunc(sysdate,'yyyy')-1+InterVal '1' year,'ddd')) as days from dual; DAYS ---- 365