简体   繁体   English

AS400 DB2 SQL-0181 日期、时间或时间戳中的值无效

[英]AS400 DB2 SQL-0181 Value in date,time or timestamp not valid

I am using a Grails App that uses queries the DB2 database using jt400 10.5 jar.我正在使用 Grails 应用程序,该应用程序使用 jt400 10.5 jar 查询 DB2 数据库。 We have a SQL statement that converts a julian date YYYYDDD to a gregorian date to display on websites.我们有一个 SQL 语句将儒略日期 YYYYDDD 转换为公历日期以显示在网站上。 However, we recently had a date and it seems to be with any date greater than 2040001 that gives this error trace.但是,我们最近有一个日期,似乎是任何大于 2040001 的日期都会给出此错误跟踪。

The SQL that I am executing is this where DELAPPT is the julian date.我正在执行的 SQL 就是 DELAPPT 是朱利安日期的地方。

 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.此语句适用于查询 DB2 的 IBM ACS Run SQL 脚本应用程序中的这些日期,但通过 JT400 似乎在日期达到 2040001 或更大时抛出此错误。 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.我在 date(digits(DELAPPT)) 等语句中尝试了几种不同的方法来执行这种转换,但我仍然遇到同样的错误。 Any ideas?有任何想法吗?

2040 is the red flag here... 2040 年是这里的红旗……

Make sure you have the JDBC connection configured to ISO formatting (or other 4 digit year) for dates.确保将JDBC 连接配置为 ISO 格式(或其他 4 位数年份)的日期。

ACS also uses JT400, since ACS works, you're already using a 4 digit year format there. ACS 也使用 JT400,因为 ACS 有效,您已经在那里使用了 4 位数的年份格式。 But if you change it to a 2 digit year, you'll be able to reproduce the error.但是,如果您将其更改为 2 位数年份,您将能够重现该错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM