amazon-redshift - redshift datediff 在使用 current_timestamp 时不起作用,但在使用 getdate() 函数时起作用

标签 amazon-redshift

我正在查询带有 datediff 的时间戳列 current_timestamp .但它给出了错误。

DATEDIFF(minute, timestamp_field ,current_timestamp::TIMESTAMP) 
or 
DATEDIFF(minute, timestamp_field ,current_timestamp)
DataType of timestamp_field is "TIMESTAMP DEFAULT '2016-03-29 20:33:33.404256'::timestamp without time zone"

输出:

ERROR: Specified types or functions (one per INFO message) not supported on Redshift tables.

Warnings: Function ""timestamp"(timestamp with time zone)" not supported. Function "timestamptz(timestamp with time zone,integer)" not supported. Function "timestamptz(text)" not supported.



但是如果我使用 ,下面的查询是有效的getdate() 功能
DATEDIFF(minute, timestamp_field ,getdate()::TIMESTAMP)

最佳答案

我只是简单地将带时区的时间戳转换为时间戳并且它正在工作。

例子:

select datediff(min, CURRENT_TIMESTAMP::timestamp, CURRENT_TIMESTAMP::timestamp);

关于amazon-redshift - redshift datediff 在使用 current_timestamp 时不起作用,但在使用 getdate() 函数时起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39702308/

相关文章:

apache-spark - 任何人都尝试使用 spark structured streaming 将数据流式传输到 Redshift

sql - 数据值 "0"在 redshift 中有无效格式错误

python - 将查询结果附加到 PostgreSQL 中的同一结果行 - Redshift

sql - PostgreSQL : How do I take multiple rows with values in different columns and combine into one row with all the values on one line?

sql - 是否有可能在一个查询中最大程度地出现我表中每个键的值?

mysql - 如何使用 Amazon Redshift 中另一个表的值更新列

python - Python-警告: Unexpected Error: <class 'IndexError' >

amazon-redshift - 如何找出 redshift 中中止查询的原因?

amazon-web-services - 您的 Amazon Redshift 数据库是否需要与机器学习模型位于同一区域?

amazon-redshift - 当表 svv_table_info 中的 stats_off 列的值为 99% 时,这意味着什么?