Some SQL functions are often used in recent projects. Post it for your use
Select datediff (day, getdate (), dateadd (month, 1, getdate () -- number of days in a month
Select convert (datetime, convert (char (8), getdate (), 120) + '1') -- the first day of a month
Select dateadd (day,-1, convert (char (8), dateadd (month, 1, getdate (), 120) + '1') -- the last day of a month
Select convert (decimal, datediff (Week, convert (datetime, convert (char (8), getdate (), 120) + '1'), dateadd (day,-1, convert (char (8), dateadd (month, 1, getdate (), 120) + '1') -- the number of days of a month's double break
-- Obtain the list of all times between two time points
Declare @ stime datetime
Set @ stime = '2017-11-01'
Declare @ times table (ID int identity, TT varchar (50 ))
While @ stime <'2017-11-30'
Begin
Insert @ times (TT) values (@ stime)
Set @ stime = convert (varchar, dateadd (day, 1, @ stime ))
End
Select * From @ times