DECLARE @day CHAR(2) SET @day = DATEPART(DAY, GETDATE()) PRINT @day
If today was the 9th of December, the above would print "9".
I want to print "09". How do I go about doing this?
Pad it with 00 and take the right 2:
DECLARE @day CHAR(2) SET @day = RIGHT('00' + CONVERT(NVARCHAR(2), DATEPART(DAY, GETDATE())), 2) print @day
2.1m questions
2.1m answers
60 comments
57.0k users