• I get an "Incorrect syntax near '='." when executing the script

    It looks like the problem is located in the @numdays=DATEDIFF.... part but can figure out the solution

    SELECT @startdate = DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0) - 30, @enddate = DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), @numdays = DATEDIFF(DAY,@startdate,@enddate))