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
 General SQL Server Forums
 New to SQL Server Programming
 convert character to Datetime

Author  Topic 

phanicrn
Starting Member

42 Posts

Posted - 2007-11-09 : 11:50:28
Hi

I have column as month and value as January, february. etcc....

can we convert this character column into date&time format.. if we do that what will be output..

I am doing test instance, when i sort by month column it's sorted in alphabetical order. when we convert this into date&time, it's sorts by date&time, it puts me right direction..

i dont know can we do this or not..

thanks
phani

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-09 : 12:23:28
look up the convert function:
select convert(datetime, '17 february 2007')

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-12 : 02:33:56
select .......
order by cast(month_value+' 2007' as datetime)

Madhivanan

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

- Advertisement -