Extract only year and month from Date

Hi, how can I convert my date column '2010-08-01' to '2010-08', only keeping year and month part. Thank you!

If you need a string with the hyphen:

convert(varchar(7),yourdate,120)

If you need an integer:

datepart(year,yourdate)*100+datepart(month,yourdate)