开发者

Get specific date range

开发者 https://www.devze.com 2023-04-12 13:14 出处:网络
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.

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

精彩评论

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