Reputation: 113
I Have a Table like this
Date value
2014-4-15 14:22:33 A
2014-4-15 13:55:7 B
2014-4-15 14:54:33 C
2014-4-15 15:11:36 D
2014-4-15 15:22:21 E
how to write a Query to delete rows which does not match the date and time range my range is "2014-4-15 15:00:00" to current time say "2014-4-15 15:30:00". After deleting rows ,my table should look like this
Date value
2014-4-15 15:11:36 D
2014-4-15 15:22:21 E
Thanks for any help
Upvotes: 1
Views: 882
Reputation: 109
delete from TABLE where DATE < '2014-4-15 15:00:00' or DATE > '2014-4-15 15:30:00';
Upvotes: 1
Reputation: 3128
You can do something like this:
SELECT * FROM TABLE1 WHERE DATE <= CURRENT_TIMESTAMP AND
DATE >= datetime('2014-4-15 15:30:00');
or for delete:
DELETE FROM TABLE1 WHERE DATE >= CURRENT_TIMESTAMP AND
DATE <= datetime('2014-4-15 15:30:00');
Upvotes: 0
Reputation: 62
Use this query:
DELETE FROM TABLE
WHERE DATE NOT BETWEEN "2014-4-15 15:00:00" AND "2014-4-15 15:30:00"
Upvotes: 0