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)
 CONVERT CAST MONTH TO NUMBER

Author  Topic 

cardgunner

326 Posts

Posted - 2008-06-06 : 09:05:53
This seams like an easy question but I have not found an answer.

What syntax do I need to use to convert "MAY" to 5 or 05?


CardGunner

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-06 : 09:48:22
declare @month varchar(10)
set @month='May'
select month(cast(@month+' 2008' as datetime))


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

cardgunner

326 Posts

Posted - 2008-06-06 : 10:29:55
PERFECT!

Thank you.

CardGunner
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-06 : 11:24:42
quote:
Originally posted by cardgunner

PERFECT!

Thank you.

CardGunner


You are welcome

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -