Hi I need help to create a query that return a result based on date interval but I can’t get it to work correctly.
I would like to achieve a result giving me the records with a date that are within a historic time span:
day -1 to -7 */from yesterday and -7 days */
day -8 to -14 */the date is between -8 and -14 days from today
For the first interval I use this where clause:
...
where `invoiceExpDate` >= date_add(now(), INTERVAL - 7 DAY)
how can I modify this to NOT give me the records for today??
For the second interval I use:
...
where datediff(invoiceExpDate,now())<= 14
AND datediff(invoiceExpDate,now())> 7
AND `invoiceExpDate` > now()
I can’t get them to work. CAn you help me with the correct where clause to return what I want?
Thanks
I think you can combine date_add() and BETWEEN
For your first clause
Similar pattern for the second.