0

I am aware that 'datetime' is not a valid data type for SQLite, but I'm not quite sure what to replace it with. Take for example the following statements, would I store it as text like the others? If so, how would I then manipulate that later on, as a date?

drop table if exists entries;
create table entries (
  id integer primary key autoincrement,
  title text not null,
  'text' text not null,
  date_created 
);
davidism
  • 121,510
  • 29
  • 395
  • 339
S.M
  • 3
  • 2

1 Answers1

0

I am aware that 'datetime' is not a valid data type for SQLite

SQLite's flexibility results in virtually any column type being valid e.g.

CREATE TABLE weidrcolumntypes (column1 rumplestiltskin, column2 weirdtestcolumn, column3 etc)

is valid and will create a table with 3 columns (4 with rowid column) :-

enter image description here

SQLite's flexibility also allows any value to be stored in any column (an exception being the rowid, for tables that are not defined using WITHOUT ROWID, where the value must be an INTEGER).

A more comprehensive answer (tagged for Android but the principles still apply) is here.

This may also be of interest.

So in brief any column type would be able to handle/store datetime.

Take for example the following statements, would I store it as text like the others?

As per above even as it is the code you have would be usable. You may wish to specify a column type of TEXT or INTEGER.


If so, how would I then manipulate that later on, as a date?

As for storing date time, Integer, Long or String could be used, the latter having the complimentary Date And Time Functions.

As such, you could do much of the manipulation within your queries which would be language independent.

MikeT
  • 51,415
  • 16
  • 49
  • 68