1

Topic: How to receive date in a format year + a date for example - 201701, 201707

How to receive date in a format year + a date for example
2017 January-201701
2017 July-201707

2

Re: How to receive date in a format year + a date for example - 201701, 201707

Romanov-krd;

declare @date datetime = getdate ();
select left (convert (varchar (8), @date, 112), 6)

3

Re: How to receive date in a format year + a date for example - 201701, 201707

WITH SQL 2012 https://technet.microsoft.com/ru-ru/library/hh213505 (v=sql.110).aspx

declare @date datetime = getdate ();
select format (@date, ' yyyyMM ')

4

Re: How to receive date in a format year + a date for example - 201701, 201707

[quote = _ human] Romanov-krd;

declare @date datetime = getdate ();
select left (convert (varchar (8), @date, 112), 6)

It is possible at once select convert (varchar (6), @date, 112)