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
 Analysis Server and Reporting Services (2008)
 Convert String to datetime

Author  Topic 

1sabine8
Posting Yak Master

130 Posts

Posted - 2010-05-10 : 05:08:37
Hi,
I am building a SSRS report where i have the string value in the format: "07/25/2010 10:44:13 CST". I need to convert it to a datetime value so i can sort the column. How is that possible to do? (or can i sort it while it's a string?)
Thanks in advance

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2010-05-10 : 05:34:27
It may help you!

select cast(left('07/25/2010 10:44:13 CST',len('07/25/2010 10:44:13 CST')-4) as datetime) from_table order by cast(left('07/25/2010 10:44:13 CST',len('07/25/2010 10:44:13 CST')-4) as datetime)

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page
   

- Advertisement -