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 2008 Forums
 Transact-SQL (2008)
 Month-yera ascending order

Author  Topic 

vipinjha123
Starting Member

45 Posts

Posted - 2012-06-13 : 01:30:47
Dear All,

i have dateofjoining column
i need to convert dateofjoining month-year format to use as a parameter
and it should come in ascending order regards,Vipin jha

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-13 : 04:10:53
select dte = convert(varchar(6),dateofjoining,112), dteparm = right(convert(varchar(10),dateofjoining,105),5)
from tbl
order by dte

or maybe you mean
select *
from tbl
where datediff(mm,dateofjoining,convert(datetime,'01-'+@mmm,105) =0
order by dateofjoining


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -