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 string to tsql datetime

Author  Topic 

Xarzu
Starting Member

25 Posts

Posted - 2011-09-22 : 04:08:08
How do I convert a string to a datetime type in T-SQL?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-22 : 04:10:08
use CONVERT() function. you need to use style value based on format in which datevalue exists in string field

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-09-23 : 05:27:53
Also you need to validate the string to see if it is a valid date

Madhivanan

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

- Advertisement -