Needs to display the date in format 'YYYYMM' instead it is displaying in for of 'yyyy-mm-dd'
declare @five date, @fiveend date
set @five = dateadd(year,-5,datefromparts(year(getdate()),1,1))
set @fiveend = datefromparts(year(getdate()),12,1)
select @fiveend
select @five
CodePudding user response:
You must apply DATE_FORMAT function to get your desired format, as follow:
SELECT DATE_FORMAT(@fiveend, '%Y%m');
SELECT DATE_FORMAT(@five, '%Y%m');
You can see here
CodePudding user response:
Try this:
select format(@fiveend(), 'yyyymm')
select format(@fiveend(), 'yyyymm')