我需要在teradata
我尝试了以下
SELECT id, person , DATE 'opendate' - DATE 'closedate'
FROM myTable1
我收到了错误
Invalid DATE literal
为什么我会拥有它 我的样本日期是
2003-12-22 2000-07-19
2011-02-04 2008-04-02
答案 0 :(得分:2)
DATE '.....'
仅适用于DATE文字,如果数据类型已经是DATE,则不需要任何内容:
SELECT id, person , opendate - closedate
FROM myTable1
否则你必须CAST:
SELECT id, person , CAST(opendate AS DATE) - CAST(closedate AS DATE)
FROM myTable1