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
 Converstion of char data type to dateime.....

Author  Topic 

sha_agrawal
Starting Member

24 Posts

Posted - 2009-07-03 : 11:05:59
I am running a update query on the basis of from date and to date. Some time it works fine and some times it throws an error 'Conversion of char date type to datetime data type resulted in an out of range datetime value'. As per some of the experts of this forum, I changed date format as "YYYY-MM-DD", even now some times it does not work.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-07-03 : 11:20:04
I think the problem is within your data.
Try:
select * from table where isdate(your_column) <> 1

That will show your records with bad data.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-05 : 02:57:50
quote:
Originally posted by webfred

I think the problem is within your data.
Try:
select * from table where isdate(your_column) <> 1

That will show your records with bad data.


No, you're never too old to Yak'n'Roll if you're too young to die.


isdate is not completely reliable you might need to add extra condition like LEN(your_column)>=8 if you're looking for format YYYY-MM-DD
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-06 : 03:57:01
quote:
Originally posted by webfred

I think the problem is within your data.
Try:
select * from table where isdate(your_column) <> 1

That will show your records with bad data.


No, you're never too old to Yak'n'Roll if you're too young to die.


Isdate() is not fully reliable
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/09/24/handle-isdate-with-care.aspx

Madhivanan

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

- Advertisement -