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)
 Unable to covert to datetime in SQL2000

Author  Topic 

kbearhome
Starting Member

36 Posts

Posted - 2003-12-17 : 15:40:07
I just upgraded a database from SQL7 to SQL2000. I am unable to convert a varchar field to a date field using a query that's worked for years in SQL7.

cast(vcustomerproduct.vchUser3 as datetime)

I get the error "Syntax error converting datetime from character string." I'm looked at the data in these fields and I don't see any strange characters. Why would this stop working in SQL2000?

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-12-17 : 16:29:17
It didn't stop working. You have data that can't be converted to datetime. Which value is it failing on?

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-12-17 : 16:41:16
Do this and tell us what you get

SELECT *
FROM vcustomerproduct
WHERE ISDATE(vchUser3)=0



Brett

8-)
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-12-18 : 01:59:34
What format is the date stored in?

Owais

We make a living out of what we get, but we make a life out of what we give.
Go to Top of Page

kbearhome
Starting Member

36 Posts

Posted - 2003-12-18 : 11:09:09
It is a varchar field and the date looks like 07/01/03.

When I run the select statement I get all nulls but one field that is incomplete date 10/31/

I replaced it with null and now the cast statement works.

Thank you.
Go to Top of Page
   

- Advertisement -