View Single Post
 
Old August 19th, 2008, 08:45 PM
Old Pedant Old Pedant is offline
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Yours was an interesting way of doing this. If I had thought of using CAST, I probably would have done
     SELECT DATEPART(mm,CAST(monthname+ ' 1, 1900' AS DATETIME))
I didn't realize you could use a partial data (month and year only) in a CAST expression.

By the by...

Another way to do this would be:
   SELECT CHARINDEX(monthname,'XXJANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC')/3 AS monthNumber