The documentation for SQLite3 datatypes says
the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values
I want to use those functions to store INTEGER
values. 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. It seems that the return type is 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. 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.
How do I force the datetime
function and friends to return a UNIX timestamp, instead of a text
value?
All the built-in date/time functions return strings.
To convert a string into a number, use CAST :
SELECT CAST(strftime('%s', 'now') AS INT);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.