remington_young 发表于 2016-11-30 10:24:35

在sqlite中怎么统计本周本月数据

  sqlite中有个表UserConsume,其中有一列rowTime,该列类型是datetime,怎么统计该表本月和本周的数据?sql如下:
--本月select *from UserConsumewhere rowTime between datetime('now','start of month','+1 second') and datetime('now','start of month','+1 month','-1 second') --本周select *from UserConsumewhere 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
  
页: [1]
查看完整版本: 在sqlite中怎么统计本周本月数据