在红移中将文本转换为时间戳 [英] Convert text to timestamp in redshift

查看:51
本文介绍了在红移中将文本转换为时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有文本值的文本字段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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆