[英]Sql Query for getting last 8 days data
For getting last 8 days details I am using this condition in my query.为了获取过去 8 天的详细信息,我在查询中使用了此条件。
bill_date <= ( CURDATE( ) - INTERVAL 8 DAY )
But I am not getting the proper result.Last 8 days means 25th april - 2nd may.但我没有得到正确的结果。过去 8 天意味着 4 月 25 日 - 5 月 2 日。 What is wrong in my condition and is there any another way to do the same?
我的情况有什么问题,还有其他方法可以做同样的事情吗?
Try this to get last 8 days details试试这个以获取过去 8 天的详细信息
bill_date >= ( CURDATE( ) - INTERVAL 8 DAY ) --After 25th Apr
or (if you have records in future date, then use this query)或(如果您在未来日期有记录,则使用此查询)
bill_date >= ( CURDATE( ) - INTERVAL 8 DAY ) AND bill_date <= CURRENT_DATE() -- From 25th Apr - 2nd May
it should be bill_date >=
( instead of <=
), because you want the result after the 25th Apr. So your condition should be bill_date >=
25th Apr.它应该是
bill_date >=
(而不是<=
),因为你想要在 4 月 25 日之后的结果。所以你的条件应该是bill_date >=
25 日。
试试这个方法
bill_date >=DATE_ADD(CURENT_DATE(),INTERVAL -8 DAY ) AND bill_date<CURRENT_DATE()
尝试这个
bill_date >= (sysdate - 8)
尝试这个
bill_date between CURDATE() - INTERVAL 8 DAY and curdate() + interval 1 day - interval 1 second
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.