Can be defined in the table variable
set @ i = '2017-01-01 00:00:00'-start time
while @i!> '2017-1-31 00:00:00'-The end time uses getdate () system time
declare @maxdate datatime
set @ i = (select min (date) from table)-start time
set @ maxdate = (select max (date) from table)-the maximum time in the table