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
精彩评论