I have an SQL query with a subselect that uses case statements to return Date and Days. Is there a way to add the Days to the Date and still have a valid Date?
The following code is as far as I have gotten. The last line won't work all the time.
20161105 + 30 days = 20161135 instead of 20161205. If I get rid of WL.Val() it appends the two expressions as strings (20161105 + 30 = 2016110530).
The following code is as far as I have gotten. The last line won't work all the time.
20161105 + 30 days = 20161135 instead of 20161205. If I get rid of WL.Val() it appends the two expressions as strings (20161105 + 30 = 2016110530).
SELECT * FROM( SELECT ID,CASE WHEN Date3 <> '' THEN Date3 WHEN Date2 <> '' THEN Date2 WHEN Date1 <> '' THEN Date1 ELSE '' END AS Date, CASE WHEN Date3 <> '' THEN Days3 WHEN Date2 <> '' THEN Days2 WHEN Date2 <> '' THEN Days1 ELSE '' END AS Days) FROM Schedule WHERE Date <> '' AND Days <> '') WHERE WL.Val(Date) + WL.Val(Days) > SUBSTRING(SysDate,0,8)