在redshift中将文本转换为时间戳 [英] Convert text to timestamp in redshift
问题描述
我有一个文本字段"presence_changed_at",其中包含文本值,即'2014/12/17 08:05:28 +0000
.我需要将其转换为时间戳.在postgreSQL中,有函数 TO_TIMESTAMP(),但是在 redshift 中似乎不支持此功能.我可以不用时间就可以得到日期
I have a text field "presence_changed_at" with text values i.e. '2014/12/17 08:05:28 +0000
. I need to convert this into timestamp. In postgreSQL there is function TO_TIMESTAMP(), however in redshift this does not seem to be supported. I can get the date without time by
TO_DATE("presence_changed_at",'YYYY/MM/DD HH24:MI:SS')
产生
2014-12-12
但是我找不到任何获取TIMESTAMP格式的方法.
but i can't find any way to get TIMESTAMP format.
预先感谢您解决
推荐答案
cast(column as timestamp)
为我工作了redshift.请参见 http://devdocs.io/postgresql~9.4/sql -expressions#SQL-SYNTAX-TYPE-CASTS
worked for me on redshift. See http://devdocs.io/postgresql~9.4/sql-expressions#SQL-SYNTAX-TYPE-CASTS
这篇关于在redshift中将文本转换为时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!