Convert BigInt timestamp to a real Date with row aggregation and operations in mySQL(在 mySQL 中使用行聚合和操作将 BigInt 时间戳转换为真实日期)
问题描述
我有一个查询,它采用上次更新日期(时间戳,但作为 bigint(20) 列),如下所示:
I have a query which takes the last update date (timestamp but as a bigint(20) column) like this:
并且它返回任何类型的日志(a 或 b)的最后更新日期(unix 时间戳作为 bigint(20)):
and it returns the last update date (unix timestamp as a bigint(20)) for any kind of log (a or b):
现在我想以日期格式格式化返回,虽然我可以像这样使用 FROM_UNIXTIME
格式化外部时间戳,但我很天真:
Now I want to format the return in date format and I naively though I can just format the outside timestamp with FROM_UNIXTIME
like this:
但它给了
我也尝试将转换放入内部查询中,但结果相同.
I tried to put the conversion in the inner queries as well but it is the same.
我还尝试在 SO、mySQL 文档和 Google 上找到答案,但没有找到为什么在我创建 group by
时转换不起作用.
I also tried to find answers on SO, mySQL documentation and Google but did not find why the conversion does not works when I make a group by
.
推荐答案
您的时间戳以毫秒为单位尝试:
Your timestamp is in milliseconds try:
(即时间除以 1000 得到秒)
(i.e. divide the time by 1000 to get seconds)
这篇关于在 mySQL 中使用行聚合和操作将 BigInt 时间戳转换为真实日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!