Hi All I'm trying to get the sum the values from a SQL database from the 11th of last month to the 10th of this month ie.
SELECT SUM(pay) AS month_pay
FROM payaccounts
WHERE dates BETWEEN 11th of last month and the 10th of this month
I am at currently using this statement to find the values from last month but now i've been told we need to change this to the 11th.
SELECT SUM(pay) AS month_pay
FROM payaccounts
WHERE (DATEPART(m, date) = DATEPART(m, DATEADD(m, - 1, GETDATE()))) AND
(DATEPART(yy, date) = DATEPART(yy, DATEADD(m, - 1, GETDATE())))