Моя цель выбрать записи с текущим месяцем (2020-04-XX)
Вот один из вариантов:
where NewMonth >= datefromparts(year(getdate()), month(getdate()), 1)
Если вам нужен верхний также:
where
NewMonth >= datefromparts(year(getdate()), month(getdate()), 1)
and NewMonth < dateadd(month, 1, datefromparts(year(getdate()), month(getdate()), 1))
Если вы хотите предыдущий месяц:
where
NewMonth >= dateadd(month, -1, datefromparts(year(getdate()), month(getdate()), 1))
and NewMonth < datefromparts(year(getdate()), month(getdate()), 1)
Или два месяца go:
where
NewMonth >= dateadd(month, -2, datefromparts(year(getdate()), month(getdate()), 1))
and NewMonth < dateadd(month, -1, datefromparts(year(getdate()), month(getdate()), 1))