sql - 从 Redshift 中的时间戳中提取时间

标签 sql amazon-redshift

我正在使用 Redshift 并希望从时间戳中提取时间。

这是时间戳:2017-10-31 23:30:00

我只想把时间设为 23:30:00

我尝试使用 cast(the_timestamp_column as time)但遇到此错误消息:
error message: Function ""time"(timestamp without time zone)" not supported.

最佳答案

使用 to_char 使用适当的格式掩码来提取时间戳的时间分量:

select to_char(the_timestamp_column, 'HH24:MI:SS')
from your_table;

Demo

关于sql - 从 Redshift 中的时间戳中提取时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47117827/

相关文章:

mysql - 将 SQL Server 2008 迁移到 MySQL 5

javascript - Codeigniter AJAX 数据返回空

sql - 如何将使用 top 1 子句的查询连接到使用聚合函数的查询?

mysql - 不在查询中的列的更新语句中的未知列

ruby-on-rails - 教 Rails 3 与 Amazon Redshift 对话 - 设置参数 "client_min_messages"的权限被拒绝

sql - 在 Redshift 上创建 Apriori 项集

sql - 查找我的数据库的 DSN?

sql - 在 Amazon Redshift 中实现 NULLS FIRST

performance - 如何设计在分析数据库上查询多个标签

sql - RedShift GROUP BY 常量列给出不一致的结果