NomerDoc Код Филиала StartDate StopDate 3209 Fil 01.04.2017 0:00 30.04.2017 0:00 3491 Fil1 01.04.2017 0:00 30.04.2017 0:00 3378 Fil2 01.04.2017 0:00 30.04.2017 0:00 3398 Fil3 01.04.2017 0:00 30.04.2017 0:00 

I need to get the same table only for each day in the interval between startdate and stopdate

  • We'll have to use an additional reference table of numbers (possibly synthetic), where there are no less than days in the longest period. Well, DATEADD (). - Akina
  • 2
    Specify which DBMS you use; this will greatly affect the answer. - German Borisov

1 answer 1

 SELECT c.DATE as [DAY],[NomerDoc] ,dm.[StartDate] ,dm.[StopDate] FROM [Calendar] c join [Table1] DM on (dm.[StartDate]<=c.[Date] and dm.[StopDate]>=c.[date]) 

Created another table with dates for each day and connected to the original table.