带偏移量的 SQLite 格式日期时间
我只想从 sqlite3 中的日期时间列返回日期。问题是我必须在其中添加偏移量。该列名为 ClientCreatedDate,值为 2011-10-24 20:53:15 +0000
通常情况下,如果该值如下所示 2011-10-24 20:53:15< /code>,我会这样做:
Select strftime('%Y-%m-%d', ClientCreatedDate) as convertedDate From Sl_Task
一切都会很好。
自从我有了偏移量之后,我能做些什么吗?
2011-10-24 20:53:15 +0000
I want to only return the date from a datetime column in sqlite3. The problem is I have to have the offset in it. The column is called ClientCreatedDate and the value is 2011-10-24 20:53:15 +0000
Normally, if the value looked like this 2011-10-24 20:53:15
, I would just do:
Select strftime('%Y-%m-%d', ClientCreatedDate) as convertedDate From Sl_Task
And everything would work great.
Is there anything I can do since I have the offset?
2011-10-24 20:53:15 +0000
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用子字符串怎么样
What about using substring
sqlite.org 上没有详细记录,但日期/时间函数确实接受时区偏移(在这种情况下,时间将转换为 UTC)。
但小时和分钟之间的冒号是必需的。
It's not well-documented on sqlite.org, but the date/time functions do indeed accept timezone offsets (in which case the time is converted to UTC).
But the colon between hours and minutes is required.