我喜欢将时间戳列转换为日期和时间格式。我该怎么写presto的查询?我的时间戳是UTC时间。非常感谢你
Timestamp format"1506929478589"
After query convert it looks like "2016-10-25 21:04:08.436"
你可以用timestamp
或date
将cast(col as date)
转换成date(col)
。
您可以使用date_format函数(docs: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'