9

我喜欢将我的时间戳列转换为日期和时间格式。我应该如何从 presto 编写查询?我的时间戳是UTC时间。非常感谢

Timestamp format"1506929478589"
After query convert it looks like "2016-10-25 21:04:08.436"
4

2 回答 2

12

您可以转换timestampdatewithcast(col as date)date(col)

于 2017-10-23T13:13:19.730 回答
4

您可以使用 date_format 函数(此处的文档:https ://prestodb.io/docs/current/functions/datetime.html )

这是一个例子:

date_format(charges.created, '%Y-%m') as rev_month

如果由于某种原因您正在比较不需要像那样进行转换的日期,您可以执行以下操作

where customers.created BETWEEN timestamp '2018-04-01 00:00:00.000' AND timestamp '2018-05-01 00:00:00.000' 
于 2018-09-06T02:50:19.967 回答