gpt4 book ai didi

sql - Hive 时间戳查询

转载 作者:可可西里 更新时间:2023-11-01 14:36:31 24 4
gpt4 key购买 nike

我创建了一个具有时间戳列(数据类型是时间戳)的配置单元表,格式如下:

2017-01-23 21:23:17.261456

但是当我这样选择时。它不能正常工作。它将选择时间戳之后的日期。该列应该是一个字符串还是我使用的查询错误?

select * from example where time_created < '2017-01-01 22:30:57.375117'

最佳答案

我有同样的问题:字符串和时间戳之间的比较不是自动完成的。这对我有用:

select * from example 
where unix_timestamp(time_created, 'yyyy-MM-dd HH:mm:ss.SSS') <
unix_timestamp('2017-01-01 22:30:57.375117','yyyy-MM-dd HH:mm:ss.SSS')

关于sql - Hive 时间戳查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42214548/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com