在红移中将文本转换为时间戳 [英] 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.
提前感谢您解决这个问题
Thanks in advance for solving this
推荐答案
cast(column as timestamp)
在 redshift 上为我工作.参见 http://devdocs.io/postgresql~9.4/sql-表达式#SQL-SYNTAX-TYPE-CASTS
worked for me on redshift. See http://devdocs.io/postgresql~9.4/sql-expressions#SQL-SYNTAX-TYPE-CASTS
这篇关于在红移中将文本转换为时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!