DB2 - FIND THE NEXT LEAP YEAR using single SELECT statement?

 Posted by Bandi on 11/30/2013 | Category: Others Interview questions | Views: 2283 | Points: 40
Answer:

Method1:
********
SELECT (YEAR (CURRENT_DATE) + 4)-(MOD (YEAR (CURRENT_DATE), 4))
FROM SYSIBM.SYSDUMMY1;

Method2:
********
SELECT
CASE MOD (YEAR (CURRENT DATE), 4)
WHEN 0 THEN YEAR CURRENT DATE) +4
WHEN 1 THEN YEAR (CURRENT DATE) +3
WHEN 2 THEN YEAR (CURRENT DATE) +2
WHEN 3 THEN YEAR (CURRENT DATE) +1
END
FROM SYSIBM.SYSDUMMY1;


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response