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 2000 Forums
 Transact-SQL (2000)
 Converting string to Datetime

Author  Topic 

jhnegrao
Yak Posting Veteran

81 Posts

Posted - 2007-10-19 : 11:07:47
Hello,

I've been trying to converting a specific string to a Datetime field, but sometimes I'm not having success.
I've traced this and I got that the following error:

Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

I saw that this error happen when I'm converting a string like that
2007-13-10 00:00:32.570

So, when I need to convert a time with 00:00 this error happen.

Anybody knows what's going on?

Have a nice weekend

Zoroaster
Aged Yak Warrior

702 Posts

Posted - 2007-10-19 : 11:18:55
Because there is no 13th month, and where you have 13 it is interpreting as a month field not a day.




Future guru in the making.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-22 : 03:26:56
What is the format of the string?
Try

Select convert(datetime,stringcol) from table
where isdate(stringcol)=1


Madhivanan

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

jhnegrao
Yak Posting Veteran

81 Posts

Posted - 2007-10-22 : 07:56:18
Hello,

What Zoroaster sad is correct and I solved the problem.
Thanks.

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-22 : 08:19:11
quote:
Originally posted by jhnegrao

Hello,

What Zoroaster sad is correct and I solved the problem.
Thanks.




How did you solve?

Madhivanan

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

- Advertisement -