I am trying to return data from the past year from the current date, for example the table...
Orders
OrderID CustomerID OrderDate
1 23 2015-10-11
the OrderDate is in format date, I am using
SELECT * FROM Orders
WHERE OrderDate BETWEEN (DATEADD(yyyy, -1, GETDATE())) AND (GETDATE());
But keep getting the error
FUNCTION db_9_9bcca.DATEADD does not exist
Does DATEADD() work with http://sqlfiddle.com/ ? Thanks.
DATEADD()
should work with sqlfiddle if you have specified an MSSQL
Server in the DDL. I did so with the following DDL to build the schema:
CREATE TABLE Orders
(OrderID int,
CustomerID int,
OrderDate date);
and ran the following query
SELECT * FROM Orders
WHERE OrderDate BETWEEN (DATEADD(yyyy, -1, GETDATE())) AND (GETDATE());
and received the following result:
Record Count: 0; Execution Time: ms