开发者

Delete old records

开发者 https://www.devze.com 2023-04-03 14:17 出处:网络
I have a column in my sqlite table which is string and has the following format 2011-09-06 18:34:55.863414

I have a column in my sqlite table which is string and has the following format

2011-09-06 18:34:55.863414

You can see that it identifies date and time. I'd like to construct a query that will delete all records that are ol开发者_如何学编程der than certain date and time. Is this possible?


Since your date is already in the best format (largest time-period values to smallest)

DELETE FROM myTable
WHERE myDateField < '2011-09-06 18:34:55.863414'

BTW -- dates are strings in sqllite, AFAIK (which is why the format matters -- biggest values to smallest, so it works alphabetically too). IF you want to treat them as dates, you can use functions. Some good examples here: http://sqlite.org/lang_datefunc.html


DELETE FROM tablename WHERE columnname < '2011-09-06 18:34:55.863414'

See: http://www.sqlite.org/lang_datefunc.html

0

精彩评论

暂无评论...
验证码 换一张
取 消