ALTER Function [dbo].[Timeseries] ( @begin datetime,@end datetime,@val int ) returns @temp Table (Times datetime) As Begin declare @MI int set @MI=datediff(MI,@begin,@end) while(@MI>=0) begin insert into @temp values(@begin) set @begin=dateadd(MI,@val,@begin) set @MI=datediff(MI,@begin,@end) end Return End