如何对数据格式为 'YYYY-MM-DD HH:MI:SS.s' 的时间戳 teradata 使用 'where clause'?
How to use 'where clause' for Timestamp teradata where the data is in format 'YYYY-MM-DD HH:MI:SS.s'?
我愿意根据问题中所述的 'YYYY-MM-DD HH:MI:SS.s' 格式数据的列过滤 table。由于这不是 teradata 中的默认时间戳格式,因此我尝试进行类型转换。
到目前为止,我尝试了以下操作:
where column_name > ${VAL1}(Timestamp(1),Format'YYYY-MM-DDbHH:MI:SS.s(1)') and column_name < ${VAL2}(Timestamp(1),Format'YYYY-MM-DDbHH:MI:SS.s(1)')
where column_name > ${VAL1}(Timestamp(0),Format'YYYY-MM-DDbHH:MI:SS.s(1)') and column_name < ${VAL2}(Timestamp(0),Format'YYYY-MM-DDbHH:MI:SS.s(1)')
where column_name > ${Val1}(Timestamp(1),Format'YYYY-MM-DDbHH:MI:SS.s(1)bt') and column_name < ${Val2}(Timestamp(1),Format'YYYY-MM-DDbHH:MI:SS.s(1)bt')
But everytime the error is same "Syntax error,expected something like
an 'OR' keyword or ')' between an integer and the integer '13'.
我认为问题在于将格式传递给 teradata。任何帮助表示赞赏。
P.S:VAL1 和 VAL2 是 bash 个变量。
您传递的变量不带引号,例如
where column_name > 2019-03-04 12:34:56.7(Timestamp(1) ...
解析器将 2019-03-04
视为计算并在 13
处停止。
尝试
where column_name > '${VAL1}'(Timestamp(1) ...
并且由于此格式 是 Teradata 的默认格式而不是转换为时间戳,您最好使用文字:
where column_name > TIMESTAMP '${VAL1}' and column_name < TIMESTAMP '${VAL2}'
我愿意根据问题中所述的 'YYYY-MM-DD HH:MI:SS.s' 格式数据的列过滤 table。由于这不是 teradata 中的默认时间戳格式,因此我尝试进行类型转换。
到目前为止,我尝试了以下操作:
where column_name > ${VAL1}(Timestamp(1),Format'YYYY-MM-DDbHH:MI:SS.s(1)') and column_name < ${VAL2}(Timestamp(1),Format'YYYY-MM-DDbHH:MI:SS.s(1)')
where column_name > ${VAL1}(Timestamp(0),Format'YYYY-MM-DDbHH:MI:SS.s(1)') and column_name < ${VAL2}(Timestamp(0),Format'YYYY-MM-DDbHH:MI:SS.s(1)')
where column_name > ${Val1}(Timestamp(1),Format'YYYY-MM-DDbHH:MI:SS.s(1)bt') and column_name < ${Val2}(Timestamp(1),Format'YYYY-MM-DDbHH:MI:SS.s(1)bt')
But everytime the error is same "Syntax error,expected something like an 'OR' keyword or ')' between an integer and the integer '13'.
我认为问题在于将格式传递给 teradata。任何帮助表示赞赏。
P.S:VAL1 和 VAL2 是 bash 个变量。
您传递的变量不带引号,例如
where column_name > 2019-03-04 12:34:56.7(Timestamp(1) ...
解析器将 2019-03-04
视为计算并在 13
处停止。
尝试
where column_name > '${VAL1}'(Timestamp(1) ...
并且由于此格式 是 Teradata 的默认格式而不是转换为时间戳,您最好使用文字:
where column_name > TIMESTAMP '${VAL1}' and column_name < TIMESTAMP '${VAL2}'