Reputation: 91
I have dates in US format, and my database supports epoch (unixtime). Is it possible to convert using the SQLite3 query?
INSERT INTO candles_USD_BCH (id, timestamp) values (null, 2018-03-31 01:02:03);
Upvotes: 1
Views: 5766
Reputation: 95532
INSERT INTO candles_USD_BCH (id, timestamp)
values (null, CAST(strftime('%s', '2018-03-31 01:02:03') as integer));
The CAST() is probably not essential in SQLite, but I think it's a good habit. The function strftime()
returns a string.
SQLite Date and Time functions, and pay attention to the section "Caveats and Bugs".
Upvotes: 3