I am using a Grails App that uses queries the DB2 database using jt400 10.5 jar. We have a SQL statement that converts a julian date YYYYDDD to a gregorian date to display on websites. However, we recently had a date and it seems to be with any date greater than 2040001 that gives this error trace.
The SQL that I am executing is this where DELAPPT is the julian date.
date(to_date(VARCHAR_FORMAT(DATE(TIMESTAMP_FORMAT(CHAR(DELAPPT),'YYYYDDD')),'MM/DD/YYYY'), 'MM/DD/YYYY'))
end as "delAppt"
Caused by: java.sql.SQLException: [SQL0181] Value in date, time, or timestamp string not valid.
at
This statement works fine with these dates in the IBM ACS Run SQL Scripts app that queries the DB2, but going through JT400 it seems to throw this error when the date reaches 2040001 and greater. I have tried a few different ways of executing this conversion in the statement like date(digits(DELAPPT)) but I'm still hitting this same error. Any ideas?
2040 is the red flag here...
Make sure you have the JDBC connection configured to ISO formatting (or other 4 digit year) for dates.
ACS also uses JT400, since ACS works, you're already using a 4 digit year format there. But if you change it to a 2 digit year, you'll be able to reproduce the error.