[sql] Convert date to YYYYMM format

I want to select value = 201301

select getdate(), cast(datepart(year, getdate()) as varchar(4))+cast(datepart(MONTH, getdate()) as varchar(2))

it returns 20131

what is the normal way to do this?

This question is related to sql sql-server tsql

The answer is


SELECT CONVERT(nvarchar(6), GETDATE(), 112)

Similar questions with sql tag:

Similar questions with sql-server tag:

Similar questions with tsql tag: