Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a pl/sql function & find leap years [closed]

Please let me know how to find a leap year through PL/SQL function. Suppose we input any number, how can we find out it is leap year or not?

like image 406
Aditya Avatar asked Apr 10 '26 13:04

Aditya


1 Answers

Try the below function,

FUNCTION leap_year_or_not(
         i_year IN NUMBER)
         RETURN VARCHAR2
IS
     l_var VARCHAR2(20);
BEGIN
     IF TO_CHAR(LAST_DAY(TO_DATE('01/02/'||i_year, 'dd/mm/yyyy')), 'DD') = 29 THEN
          l_var := 'Leap Year';
     ELSE
          l_var := 'Not Leap Year';
     END IF;
     RETURN l_var;                 
END;
like image 155
Dba Avatar answered Apr 13 '26 07:04

Dba



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!