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
 Transact-SQL (2000)
 converting the month to two characters

Author  Topic 

ALBean
Starting Member

12 Posts

Posted - 2004-06-02 : 16:11:05
select convert(char(2), datepart(month,getdate()))

The above code will convert to a 6 with a space after it. Is there a clever way to get it convert to "06" instead?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-06-02 : 16:14:09
SELECT RIGHT('0' + CONVERT(VARCHAR(2), MONTH(GETDATE())), 2)

Tara
Go to Top of Page

ALBean
Starting Member

12 Posts

Posted - 2004-06-02 : 16:20:22
Tara, thanks for slaying that dragon for me!
Go to Top of Page
   

- Advertisement -