Try This:

create table #month (monthname varchar(50))

insert into #month (monthname)
values ('May')
insert into #month (monthname)
values ('March')
insert into #month (monthname)
values ('April')
insert into #month (monthname)
values ('January')
insert into #month (monthname)
values ('February')
insert into #month (monthname)
values ('June')




select monthname
from #month 
order by month(convert(datetime, monthname + ' 01 2001',101))

drop table #month 



Dharmendar Kumar
http://www.realmagnet.com
http://www.daksatech.com





-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 12, 2007 10:57 AM
To: SQL
Subject: RE: Sort by month


Tried this, but since it is not stored as a date but varchar, datepart will
not work.

-----Original Message-----
From: Mike Hughes [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 12, 2007 10:40 AM
To: SQL
Subject: Re: Sort by month

Try
In Selectstaement add
 DATEPART(dd, Birthdate) AS DayOfBirth";

OrderByStatement = "ORDER BY DayOfBirth"


On 7/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I have a table with the month stored as January, February,
> March.....etc. How do I write a query to order by month so that 
> January is first, Feb second and so on? I'm using SQL server and
ColdFusion.
>
>
>
>
>
> 





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade & see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR

Archive: http://www.houseoffusion.com/groups/SQL/message.cfm/messageid:2873
Subscription: http://www.houseoffusion.com/groups/SQL/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6

Reply via email to