[Solved] How to find all the timestamp values interval by each minute between the two timestamp records


Here is one option using an ad-hoc tally/numbers table and a Cross Apply

Example

Declare @YourTable Table ([Id] int,[Open Date] datetime,[Close Date] datetime)  Insert Into @YourTable Values 
 (1,'2019-07-03 16:28:39.497','2019-07-04 16:28:39.497')
,(2,'2019-07-04 15:28:39.497','2019-07-05 19:28:39.497')

Select A.*
      ,TSRange = DateAdd(Minute,N,convert(varchar(16),[Open Date],20))
  From @YourTable A
  Cross Apply (
                Select Top (DateDiff(MINUTE,[Open Date],[Close Date])-1) N=Row_Number() Over (Order By (Select NULL)) 
                  From master..spt_values n1, master..spt_values n2
              )  B

Returns

enter image description here

6

solved How to find all the timestamp values interval by each minute between the two timestamp records