asked on
DECLARE @startdate DATETIME
,@enddate DATETIME;
SET @startdate = '2016-03-06';
SET @enddate = '2016-03-20';
WITH calendardates
AS ( SELECT date1 = @startdate
UNION ALL
SELECT DATEADD(DAY, 1, date1)
FROM calendardates
WHERE DATEADD(DAY, 1, date1) <= @enddate
)
Select c.date1,[declared_at],[branch],[Day_Time2],[Shop_Time],[Shop_Time_Declared_At],[Store_Close_Time]
from [Bank_Activity_Declared_At_Time] BA
right JOIN calendardates c
ON DATEADD(dd, 0, DATEDIFF(dd, 0, BA.declared_at)) = c.date1
where branch = 227
and declared_at >='2016-03-06'
and declared_at <= '2016-03-20'