-- 当月第一天
select dateadd(month, datediff(month, 0, getdate()), 0)
-- 当月最后一天(思路:下月的第一天减去一天)
select dateadd(month, datediff(month, 0, dateadd(month, 1, getdate())), -1)
--取某月第一天:
SELECT CAST((LEFT('201902',4)+'-'+SUBSTRING('201902',5,LEN('201902'))+'-'+'01') AS DATETIME)
--取某月最后一天:
SELECT DATEADD(DAY,-1,DATEADD(MONTH,1,CAST((LEFT('201902',4)+'-'+SUBSTRING('201902',5,LEN('201902'))+'-'+'01') AS DATETIME)))