[英]How can I convert a datetime string to a UNIX timestamp in SQLite3?
The documentation for SQLite3 datatypes says SQLite3数据类型的文档说
the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values SQLite的内置日期和时间函数能够将日期和时间存储为TEXT,REAL或INTEGER值
I want to use those functions to store INTEGER
values. 我想使用这些函数来存储INTEGER
值。 How do I do so? 我该怎么办? The documentation for SQLite3 datetime functions describes the types of the arguments to those functions, but says nothing of the return type. SQLite3 datetime函数的文档描述了这些函数的参数类型,但没有提到返回类型。 It seems that the return type is text
: 似乎返回类型是text
:
sqlite> select typeOf(datetime('2014-12-12 12:12:12.000'));
text
This is not what I want -- I want an integer value representing that time as a UNIX timestamp. 这不是我想要的 - 我想要一个整数值来表示该时间作为UNIX时间戳。 Even when I create a column of type integer
and attempt to store a datetime(...)
value in it, SQLite stores it as a text
value in that integer
column. 即使我创建了一个integer
类型的列并尝试在其中存储datetime(...)
值,SQLite也将其作为text
值存储在该integer
列中。
How do I force the datetime
function and friends to return a UNIX timestamp, instead of a text
value? 如何强制datetime
函数和朋友返回UNIX时间戳而不是text
值?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.