I am going nuts with datetime and SQL Server.
I have (example) Aug 4 2011 12:00AM
How do I convert this to a datetime (or smalldatetime) type.
convert(datetime, 'Aug 4 2011 12:00AM')
EDIT: it works
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This does work for me on SQL Server 2008.
What’s happening is an implicit conversion, though, not always trustworthy. The format specifier for your date format is
100, found in the table on the CAST and CONVERT docs. Try this: