June 29, 2011 at 12:19 am
I am trying to get records for the previous day which is fine apart from running it on Monday which will need Fridays records.
The first part of the where with the case statements is not working?
SELECT *
FROM invoice_head INNER JOIN
invoice_lines ON invoice_head.Invoice_id = invoice_lines.Invoice_id INNER JOIN
companies ON invoice_head.company_id = companies.company_id AND invoice_head.Optional_1 = companies.companyname
WHERE (invoice_line.ApproveDate >= (CASE WHEN datepart(dw, getdate())=2 THEN (getdate()-3) ELSE (getdate()-1)))
AND (invoice_lines.ApproveDate < DATEADD(day, DATEDIFF(day, 0,GETDATE()), 0))
AND (companies.company_id = 44)
ORDER BY companies.companyname
June 29, 2011 at 12:57 pm
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy