如何在SQLite中将时间戳转换为字符串? [英] How to convert timestamp to string in SQLite?
本文介绍了如何在SQLite中将时间戳转换为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在其中存储了带有时间戳(ms)的表。我想将这些时间戳转换为易于理解的格式。
I have table with timestamps in ms stored in it. I want to convert those timestamps in a human readable form.
这是我的表格的示例输出:
Here is a sample output of my table:
SELECT date raw, strftime('%d-%m-%Y', (date/1000)) as_string
FROM my_table
+-----------------+--------------+
| raw | as_string |
+-----------------+--------------+
| 1444687200000 | 06-47-3950 |
+-----------------+--------------+
... ... ...
+-----------------+--------------+
如您所见,字符串日期很奇怪( 06-47-3950
)
As you can see, the date as string is quite strange (06-47-3950
).
如何获取 2015年12月10日
?
推荐答案
尝试一下:
SELECT date raw, strftime('%d-%m-%Y', datetime(date/1000, 'unixepoch')) as_string
FROM my_table
您需要将时间戳记转换为之前的日期。
You need to convert timestamp to date before.
这篇关于如何在SQLite中将时间戳转换为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文