Skip to content

Instantly share code, notes, and snippets.

@solicomo
Last active December 17, 2015 14:39
Show Gist options
  • Save solicomo/5626303 to your computer and use it in GitHub Desktop.
Save solicomo/5626303 to your computer and use it in GitHub Desktop.
SQLite 删除一年前的数据
SQLite 没有 datediff() ,所以要删除一年前的数据需要如下语句:
1. 删除(从今天零点算起的) 365 天前的数据:
delete from tb_load_info where julianday(strftime('%Y-%m-%d',datetime('now','localtime'))) - julianday(strftime('%Y-%m-%d', created_at)) > 365;
2. 删除(从此时此刻算起的) 365 天前的数据:
delete from tb_load_info where julianday(datetime('now','localtime'))-julianday(created_at) > 365;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment