xxxxxxxxxx
select convert(varchar, getdate(), 111) yyyy/mm/dd 2022/12/30
select convert(varchar, getdate(), 112) yyyymmdd 20221230
xxxxxxxxxx
--C. FORMAT Function (new in SQL 2012) use format = yyyyMMdd returning the results as nvarchar.
SELECT FORMAT([MyDate],'yyyyMMdd') as 'MyDate', FORMAT([MyDateTime],'yyyyMMdd') as 'MyDateTime'
FROM [dbo].[TestDate];