user4627062
user4627062

Reputation:

SQLite delete rows prior to date

I have a column timestamp of data type TEXT in an SQLite table.

I want to delete everything prior to 2015-03-01 00:00:00 (YYYY-MM-DD HH:MM:SS).

What is the correct way to do so?

Upvotes: 0

Views: 57

Answers (1)

Simulant
Simulant

Reputation: 20122

delete from tablename where timestamp < '2015-03-01 00:00:00';

The natural order of Strings (Text) is the same as of timestamps if your are using the date-format like above starting with the most significant value (year) on the left.

Upvotes: 1

Related Questions