Sqlite - Time

Sqlite - Time

Time

Sqlite does not support natively the storage of a time data type. It lets you choose between text and number (see date and time datatype in Sqlite. ie

  • 2020-10-14 21:06:46.507 (Iso string)
  • 1602702406 (Epoch Seconds called unixepoch in the date time function of Sqlite)

By default, tabulify has chosen to save the date in the text (ie SqlLiteral) format because:

You can control this behavior by setting the time configuration built-in attributes

Example

With tabulify, by default, you would be able to manipulate them with the Sqlite Date Time function like that:

  • Date
SELECT date('2020-10-15','-1 day')
-- or 
SELECT date(dateColumn,'-1 day') from table;
  • Timestamp (Datetime)
SELECT datetime('2020-10-15 16:34:56.607','-1 seconds')
-- or 
SELECT datetime(timestampColumn,'-1 seconds') from table;
  • Time
SELECT time('22:10:23','+1 seconds') 
-- or 
SELECT time(timeColumn,'+1 seconds')  from table;
Powered by ComboStrap