导出带有时间戳列 SQL 错误“-180”的 DB2 table 过滤器

Export DB2 table filter with timestamp column SQL error "-180"

我正在尝试从 table 导出数据,其中在时间戳列上添加了过滤器,但它返回 SQL 错误“-180”SQLSTATE=22007。

EXPORT TO "e:\temp\SPO_DPDN_DET.csv" OF DEL MODIFIED BY coldel, codepage=1208 MESSAGES "e:\temp\SPO_DPDN_DET.log"
select * from mcare.SPO_DPDN_DET001 where SP_CODE in('919097','919025') AND APPR_TIME BETWEEN '11.07.2017' and '24.07.2017';

APPR_TIMETimestamp 列。我收到此错误:

SQL3104N The Export utility is beginning to export data to file "e:\temp\SPO_DPDN_DET.csv".

SQL3015N An SQL error "-180" occurred during processing.

SQL0180N The syntax of the string representation of a datetime value is incorrect. SQLSTATE=22007

SQL3105N The Export utility has finished exporting "0" rows.

如果 APPR_TIME 的数据类型是 "timestamp" 则使用有效的时间戳文字,否则如果它是数据类型 "date" 则使用有效的日期文字。

更易于使用 ISO 格式文字,时间戳文字的示例是“2017-07-11-00.00.00.000000”,或者日期是“2017-07-11”(7 月 11 日,即 yyyy- mm-dd 格式)。

你的 between 在时间戳上不起作用,就像毛向你解释的那样,你也可以像这样转换为日期:

select * from mcare.SPO_DPDN_DET001 
where SP_CODE in ('919097','919025') 
AND date(APPR_TIME) BETWEEN '2017-07-11' and '2017-07-24';