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 2005 Forums
 Transact-SQL (2005)
 Convert string to datetime

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2007-10-26 : 15:47:10
How to convert string of date to datetime?
For example, '2/10/2007' to 2/10/2007.

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-10-26 : 16:03:01
Just out of curiosity, before posting your question here, where did you look to find the answer? Did you try looking in Books On Line, or try a google search? I ask because it seems hard to believe that you could not find the answer very easily, especially since you use the key word -- CONVERT -- right in your question.

Asking for help is great, but learning to find answers on your own is even greater.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-10-27 : 00:39:50
Use convert function. Datetime type contains date and time, so don't know why you want to convert '2/10/2007' to 2/10/2007.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-27 : 03:50:59
"don't know why you want to convert '2/10/2007' to 2/10/2007

I imagine its the same as the OPs earlier question (which has already been answered)

How to sort string of date?

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-29 : 01:28:55
quote:
Originally posted by Sun Foster

How to convert string of date to datetime?
For example, '2/10/2007' to 2/10/2007.


Always use proper DATETIME datatype to store dates. It is your front end application where you need to format. Dont store formatted dates in a table

Madhivanan

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

- Advertisement -