Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: leap year

RE: leap year

From: Mercadante, Thomas F (LABOR) <Thomas.Mercadante_at_labor.state.ny.us>
Date: Tue, 24 May 2005 10:17:09 -0400
Message-ID: <ABB9D76E187C5146AB5683F5A07336FF16E627@EXCNYSM0A1AJ.nysemail.nyenet>


Inessa,

How about this. Pretty simple and it works!

declare

  start_year number :=3D 1981;
  end_year number :=3D 1990;
  indx number :=3D start_year;

  success_count number :=3D 0;
  test_date date;
begin

  while indx < end_year loop
    begin

	  select to_date(to_char(indx)||'0229','yyyymmdd')
	    into test_date
		from dual;
      dbms_output.put_line(indx || ' ok'); =20
      success_count :=3D success_count + 1;
      exception
	     when others then
		      dbms_output.put_line(indx || ' error'); =20
    =20
    end;
    indx :=3D indx + 1;
  end loop;
dbms_output.put_line('success_count =3D ' || success_count); end;

Dbms_Output results

1981 error
1982 error
1983 error
1984 ok
1985 error
1986 error
1987 error
1988 ok
1989 error
success_count =3D 2

-----Original Message-----

From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Inessa Weiner Sent: Tuesday, May 24, 2005 10:01 AM
To: oracle-l_at_freelists.org
Subject: leap year

Hi,

I need to write a PL/SQL function to
show how many times the leap year occurred between two dates. The maximum range between dates is 10 years.

Please help.
Thanks,
Inessa.=20

--

http://www.freelists.org/webpage/oracle-l
--

http://www.freelists.org/webpage/oracle-l Received on Tue May 24 2005 - 10:21:59 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US