Results 1 to 3 of 3

Thread: Try this to Test for Leap Year

  1. #1
    Contributing Member
    Join Date
    Nov 2007
    Answers
    53

    Try this to Test for Leap Year

    Dear All,

    Test for Leap Years

    select year,
    decode( mod(year, 4), 0,
    decode( mod(year, 400), 0, 'Leap Year',
    decode( mod(year, 100), 0, 'Not a Leap Year', 'Leap Year')
    ), 'Not a Leap Year'
    ) as leap_year_indicator
    from my_table


    Have a pleasant time




  2. #2
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Try this to Test for Leap Year

    What about simply using this one.
    Code:
    SELECT DECODE(TO_CHAR(LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE,'  y'),1)),'DD'),28 ,'Not a Leap Year','Leap Year')   FROM dual



  3. #3
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Try this to Test for Leap Year

    Try this also

    Code:
    SELECT DECODE((LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE,'YYYY'),11)) - TRUNC(SYSDATE,'YYYY'))+1,365,'NOT A LEAP YEAR',366,'LEAP YEAR') FROM DUAL;



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact