I was running a query today and was not able to SUM by the current month. I checked the code and didn’t see any issues there, but when I looked at the variables it was pretty obvious.
DECLARE @targetdate VARCHAR(8) DECLARE @previousdate VARCHAR(8) DECLARE @currentmonth INT DECLARE @currentday INT
SET @targetdate = CONVERT(VARCHAR(8), GETDATE() [...]