I have an integer column "Month" I would like to get 2 digit number for month.
This is what I have tried: DATEPART(mm, @Date)
It returns one digit for months January to September I am using SQL Server 2008
Anyone has suggestion?
there are different ways of doing it
like
SELECT RIGHT('0' + RTRIM(MONTH('12-31-2012')), 2);
like
SELECT SUBSTRING(CONVERT(nvarchar(6),getdate(), 112),5,2)
see Fiddle
There may be other ways to get this.