Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 date...

Author  Topic 

tran008
Starting Member

38 Posts

Posted - 2004-05-27 : 14:52:09
Hi All,

How can I return the leading 0 for month that is less then 10. Select month(getdate()) will only return 5. I want to add 0 to it.

thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-05-27 : 14:55:01
[code]


SELECT
CASE
WHEN MONTH(GETDATE()) < 10 THEN '0' + CONVERT(CHAR(1), MONTH(GETDATE()))
ELSE CONVERT(CHAR(2), MONTH(GETDATE()))
END

[/code]

Tara
Go to Top of Page

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2004-05-27 : 15:54:45
SELECT RIGHT('0' + CONVERT(VARCHAR(2), MONTH(GETDATE())), 2)
Go to Top of Page
   

- Advertisement -