Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string to date

Status
Not open for further replies.

MsMellow

Programmer
Sep 5, 2007
7
US
Hi,

Does anyone know how to convert 'Oct-09-07' to a date data type?

Thank you!
 
Thank you.

I think that the problem might be that even through we are using SQL SERVER 2005, our instance is still SQL SERVER 2000.

I get error:

'The conversion of a char data type to a datetime data type resulted in an out-of-range datatime value' for the code you gave and all else that I have tried.

MsMellow
 
>> I think that the problem might be that even through we are using SQL SERVER 2005, our instance is still SQL SERVER 2000.

No. This particular behavior has not changed from 2000 to 2005. I suspect that you have some bad data.

To find your bad data...

Code:
Select *
From   [!]TableName[/!]
Where  IsDate(replace([!]DateColumn[/!],'-',' ')) = 0

Of course, you will need to replace DateColumn and TableName to match the names in your database.


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top