I have to insert two date fields(EFFECTIVE & EXPIRATION DATE) in a table in which effective date will be current date and expiration is of 2 yrs exactly from that date . I know we can do in SELECT SQL statement by number of days adding to current date but if in between if leap year falls then we need to have 1 more day extra . I can check for successive years for leap year check thru COBOL but is there anything i can handle in SQL query itself
can any one guide me .
SELECT CURRENT_DATE + 730 or 731 DAYS
WITH UR ;
CASE (mod(year(current date), 400)) WHEN 0 THEN 366
CASE (mod(year(current date), 4)) WHEN 0 THEN
CASE (mod(year(current date), 100)) WHEN 0 THEN
365 ELSE 366 END
ELSE 365 END
This should give you days and handle leap year and can be used in your original post if you don't want above.