sqlite中有个表UserConsume,其中有一列rowTime,该列类型是datetime,怎么统计该表本月和本周的数据?sql如下:
--本月 select * from UserConsume where rowTime between datetime('now','start of month','+1 second') and datetime('now','+1 month','-1 second') --本周 select * from UserConsume where rowTime between datetime(date(datetime('now',strftime('-%w day','now'))),'+1 second') and datetime(date(datetime('now',(6 - strftime('%w day','now'))||' day','1 day')),'-1 second')
主要用的函数有datetime和strftime,具体用法,请参阅官网:http://www.sqlite.org/lang_datefunc.html
sql,请参阅:http://sqlite.org/lang.html
数据类型,请参阅:http://sqlite.org/datatype3.html