I'm creating a query in MSSQL (for SAP Business One) to compare sales and profit on a given date range (using between [date] and [date]) with the sales and profit for the same date range of last year, but I don't know how to do that.
I'm using the following code for the date range:
WHERE t1.docdate between '[%1]' and '[%2]'
thank you
Add and Subtract Dates using DATEADD in SQL Server
Be aware of the implications of using
between, as shown here: Bad habits to kick : mis-handling date / range queries - Aaron Bertrand - 2009-10-16