I'm trying to write a SQL query that will select data between 2/2/2006 and yesterday - to be run on a daily basis. I have:
SELECT AuditId, Audit_Date AS ADate
FROM dbo.Audit_Table
WHERE Audit_Date BETWEEN (Audit_Date > CONVERT(DATETIME, '2006-02-06 00:00:00', 102) and (DATEDIFF(d, Audit_Date, GETDATE() - 1) = 0)
I get an error - Incorrect syntax near '>'.
Any help with this is appreciated.
SELECT AuditId, Audit_Date AS ADate
FROM dbo.Audit_Table
WHERE Audit_Date BETWEEN (Audit_Date > CONVERT(DATETIME, '2006-02-06 00:00:00', 102) and (DATEDIFF(d, Audit_Date, GETDATE() - 1) = 0)
I get an error - Incorrect syntax near '>'.
Any help with this is appreciated.