SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))

set @date=CONVERT(varchar(8), GETDATE(), 112)

Where tsa.TimeByDay between cast(@StartDate as Date) and cast(@EndDate as DATE)