使用SQLite获取本周的数据 [英] Get this week's data using SQLite

查看:288
本文介绍了使用SQLite获取本周的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图用sqlite获取本周的数据,但似乎我错过了一些东西,因为我收到了错误的信息。具体来说,我想检索数据库中所有带有时间戳的数据,其日期在本周。这个星期可能从星期日或星期一开始,即26/2 / 12-03 / 03/12。此刻我正在使用这样的东西: SELECT * FROM myTable WHERE DATE(timeStamp)== DATE('now','weekday 0','-7 days')

I am trying to get this week's data in sqlite but it seems that I have missed something as i get wrong information back. To be more specific i want to retrieve all the data in my database that have a timestamp which its date falls in this week. This week may either start from Sunday or Monday i.e 26/2/12-03/03/12. At the moment I am using something like this: SELECT * FROM myTable WHERE DATE(timeStamp) == DATE('now', 'weekday 0', '-7 days')

推荐答案

我认为您应该非常接近。如果您希望自本周开始以来拥有所有功能,只需稍作修改即可:

I think you should be pretty close. If you want everything since the start of this week, just a slight modification:

SELECT * FROM myTable WHERE DATE(timeStamp) >= DATE('now', 'weekday 0', '-7 days');

这篇关于使用SQLite获取本周的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆