从亚马逊redshift中的now()中提取时间

时间:2018-09-27 08:49:39

标签: sql amazon-redshift

我正在尝试仅从Amazon redshift中的日期时间字符串中提取时间部分(毫秒除外)。

我用过:

Select now()::time;

但这给了我错误。

Error running query: Specified types or functions (one per INFO message) not supported on Redshift tables

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:1)

我不太确定该错误,但是我同意乔恩·斯科特(Jon Scott)的评论,下面的查询运行正常,没有任何错误。

Select now()::time;

它输出类似:

  

09:23:49.697401

它包含秒后的6位数字。

如果您仅将time参数最多添加,则如下所示几秒钟后您需要多少个数字。这里是0

Select now()::time(0);

这将输出:

  

09:23:49

如果这样做;

Select now()::time(1);

这将输出:

  

09:23:49.6

希望它能回答您的问题。

答案 1 :(得分:0)

使用下面的select子句返回时间所需的确切结果

Select CURRENT_TIME::time(0);