Declare @ tmpdate datetime
Select @ tmpdate = dateadd (week, 2, '2017-08-26 ')
Select @ tmpdate = getdate ()
-- Select datepart (weekday, @ tmpdate)
-- The first day of a week (the first day of a week on Monday ):
Select dateadd (day,-datepart (weekday, @ tmpdate) + 2, @ tmpdate)
-- The last day of a week (the first day of a week on Monday ):
Select dateadd (day, 8-datepart (weekday, @ tmpdate), @ tmpdate)
-- The first day of the month
Select dateadd (day,-day (@ tmpdate) + 1, @ tmpdate)
-- The last day of the month (note that the first day of the month in the next month is the last day of the month)
Select dateadd (day,-day (dateadd (m, 1, @ wDate), dateadd (m, 1, @ wDate ))
-- The first day of the season
Select dateadd (qq, DATEDIFF (qq, 0, getdate (), 0)
-- The first day of the year
Select dateadd (yy, DATEDIFF (yy, 0, getdate (), 0)
-- Calculate the number of days on January 1, January.
Select date = @ tmpdate, days = 32-day (@ tmpdate + 32-day (@ tmpdate ))