DROP TABLE #MTD ' ,@endDate date = cast(getdate() as date) CREATE TABLE #MTD(bydate date) DECLARE @count int = DATEDIFF(day,@startDate,@endDate) BEGIN INSERT INTO #MTD(bydate) SELECT DATEADD(day,@count,@startDate) ; END ------------------------------…