9951 explained code solutions for 126 technologies


sqliteHow do I store a datetime type in a SQLite database?


Storing a datetime type in a SQLite database can be done using the DATETIME data type. Below is an example of how to store a datetime type in a SQLite database. The example code creates a table called "events" with a column called "date" of type DATETIME and inserts a datetime value into it.

CREATE TABLE events (date DATETIME);
INSERT INTO events VALUES (datetime('now'));

Code explanation

  1. CREATE TABLE events (date DATETIME): This creates a table called "events" with a column called "date" of type DATETIME.
  2. INSERT INTO events VALUES (datetime('now')): This inserts a datetime value into the "events" table.

Helpful links

Edit this code on GitHub