开发者

Julian Day to ISO 8601 string in SQLite

开发者 https://www.devze.com 2023-04-09 08:27 出处:网络
I have a table that stores date/time v开发者_运维问答alues as julian days in SQLite (using the julianday() function). I can\'t seem to figure out how to convert them back to ISO 8601 style strings (YY

I have a table that stores date/time v开发者_运维问答alues as julian days in SQLite (using the julianday() function). I can't seem to figure out how to convert them back to ISO 8601 style strings (YYYY-mm-ddThh:m:ss.sss) when I read them?


Just feed the Julian day number to the datetime function:

A time string can be in any of the following formats:
[...]
12. DDDDDDDDDD
[...]
Format 12 is the Julian day number expressed as a floating point value.

So datetime(julianday_output) goes in the opposite direction as the julianday function:

sqlite> select datetime(julianday(current_timestamp)) as dt_from_jd, current_timestamp as dt;
dt_from_jd          | dt
2011-09-30 14:46:52 | 2011-09-30 14:46:52


Have you tried strftime? http://www.sqlite.org/lang_datefunc.html

0

精彩评论

暂无评论...
验证码 换一张
取 消