Delete specific date entries in sqlite?

I have a table with a column called timestamp

timestamp DATE DEFAULT (datetime('now','localtime'))

which stores the entries in the table as follows:

2010-12-06 18:41:37

How to delete records of a certain date? I use:

DELETE FROM sessions WHERE timestamp = '2010-12-06';

but it does not work. Did I miss something?

thank you in advance.

+3
source share
2 answers
DELETE FROM sessions WHERE timestamp = '2010-12-06' 

basically selects and deletes any entries marked as "2010-12-06 00:00:00"

You better define a range:

DELETE FROM sessions WHERE timestamp >= '2010-12-06' AND timestamp < '2010-12-07'

will delete any sessions that have fallen in this range.

+6
source

Use the Date function to extract and compare only the date:

DELETE FROM sessions WHERE DATE(timestamp) = '2010-12-06'
0
source

Source: https://habr.com/ru/post/1778849/


All Articles