I am running this query:
select member, customerinfo.customerid -- ...other irrelevant columns...
from customerinfo, addressinfo
where customerinfo.customerid = addressinfo.customerid
and MEMBER = (Date(GetDate()-1))
and addressinfo.addresstype = 's'
I it is obviously giving me data if Member = yesterday.
My question is, how do I structure the query to give me data if Member = the last 2 days (yesterday and the day before)?
MEMBER BETWEEN (GETDATE() -2) AND (GETDATE() -1)
In SQL Server you can also try:
MEMBER BETWEEN DATEADD(day, -2, GETDATE()) AND DATEADD(day, -1, GETDATE())
Change your query in:
SELECT member, customerinfo.customerid, ContactName, Address1,
Address2, City, State, ZIP, Country from customerinfo, addressinfo
WHERE customerinfo.customerid = addressinfo.customerid
and MEMBER >= (Date(GetDate()-2)) AND MEMBER <= (Date(GetDate()-1))
and addressinfo.addresstype = 's'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With