I am completely new to sql. Tell me, please, is it possible to make it so that all dates are deleted more than the current month and less than a certain date? All months in the format of the words "June". My construction is clearly incorrect:
delete from www where [Источник]='База' and ([год]<=2017) or ([год]=2018 and [месяц] <= DATENAME(month, GETDATE())) Initially it was like this:
delete from www where [Источник]='База' and ([год]=2016 and [месяц] not in ('Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь')) or ([год]=2017 and [месяц] not in ('Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь')) or ([год]=2018 and [месяц] not in ('Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь') The correct solution (another column was chosen for comparison):
delete from www where [Источник]='База' and ([Дата] < CONVERT(datetime, '2016-05-01') or [Дата] > eomonth(getdate()))
[дата]field and compare dates with dates. - MaxU