whenever possible I do these calculations in SQL server. Using SQL server, the syntax is simple. DB2 is a bit more complex. Here are examples in both.
select convert(datetime, convert(varchar, fieldname + 19000000)) from …
SELECT date(substr(digits(fieldname + 19000000),2,4)||’-‘||substr(digits(fieldname + 19000000),6,2)||’-‘|| substr(digits(fieldname + 19000000),8,2)) FROM library/file
I’m assuming you’re YYYMMDD is 990227 for 1999 and 1070227 for 2007, and that the dates are stored in a numeric field. if they’re in a string field things are a bit more complex, but not impossible. Once you have the fields in a datetime format, you can use normal date comparison/arithmetic on them.
Hope that helps,