I am trying to use this query to bring back yesterdays data, ---- represents columns/tables
DECLARE @today date = GETDATE()
SELECT *
FROM ------
LEFT JOIN -----
ON ------ = ----
WHERE ------.DATE_TIME >= @today
AND -----.DATE_TIME < DATEADD(DAY, -1, @today)
I have used this DECLARE STATEMENT before and it worked but never with a join.
I am getting this error back error
Error text:
incorrect syntax near "DECLARE": line 1 col 1 (at pos 1) OpenSQLExceptionCategories: [NON_TRANSIENT, SYNTAX_ERROR]
Yesterdays data, is there another way of doing this?