开发者

Get specific date range

I'm using

SELECT * from tbl_name WHERE DATE_SUB(CURRENT_DATE(), INTERVAL 3 DAY)

to select d开发者_如何学Pythonata for specific days. The problem is that line gets data right before 3 days. What to do so selected data to be period three days before till now ?


First your field should be of type datetime or date and then you can use a between clause

your_date_field BETWEEN now() - INTERVAL 72 HOURS AND now()
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜