我想只从sqlite3中的datetime列返回日期。问题是我必须要有偏移量。该列名为ClientCreatedDate,值为2011-10-24 20:53:15 +0000
通常,如果值看起来像2011-10-24 20:53:15
,我会这样做:
Select strftime('%Y-%m-%d', ClientCreatedDate) as convertedDate From Sl_Task
一切都会很好。
因为我有偏移量,我能做些什么吗?
2011-10-24 20:53:15 +0000
答案 0 :(得分:2)
如何使用substring
Select strftime('%Y-%m-%d', substr(ClientCreatedDate,1,19) as ....
答案 1 :(得分:2)
在sqlite.org上没有详细记录,但the date/time functions确实接受时区偏移(在这种情况下,时间转换为UTC)。
> SELECT DATETIME('2012-01-07 13:51:40 -06:00');
2012-01-07 19:51:40
但需要小时和分钟之间的冒号。