I have below query and i want to get datetime in 30 min intervals between 2 datetime. Basicly I got it, but is limitited and wouln\'t return al results if the timediff is over 2
Please see if this works.
declare @DateTime1 DateTime = '2016-11-24 18:00:00'
declare @DateTime2 DateTime = '2016-11-25 18:00:00'
declare @Interval DateTime = @DateTime1
declare @vartmptable table(DT DateTime)
While (@Interval < @DateTime2)
begin
--select @Interval, FORMAT(@Interval,'dd-HH:mm')
insert into @vartmptable select @Interval
set @Interval = DATEADD(mi,30,@Interval)
end
select FORMAT(DT,'dd-HH:mm') from @vartmptable