I have a report that I need to run every so often, but I need to manually update the date range. It will always be for a specific month, and currently I just update the entire fields as such in my WHERE clause:
SQL
AND(invoice_lines.invoice_date=CONVERT(DATETIME,'2019-08-01 00:00:00',102))AND(invoice_lines.invoice_date<CONVERT(DATETIME,'2019-09-01 00:00:00',102))
The code example above are lines 23 and 24
What I would like to do is create variables at the top of the script where I can say $month = '8' and $year = '2019'.
What I have tried:
DECLARE $from DATETIME as well asDECLARE $from VARCHAR(255)
DECLARE $month VARCHAR(2)
SET $month = '8'
SET $from = CONVERT(DATETIME, '2019-' + $month +'-01 00:00:00') as well as '2019-' += $month += '-01
I have also tried many other variations, but I cannot seem to figure out what I am doing...
<