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
If you want the data for the same date range last year, you have two choices:
or
Notes:
between
with dates. However, I'm leaving the logic as is because that is how the oP phrased the question.