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)
 Help with Convert

Author  Topic 

SunnyDee
Yak Posting Veteran

79 Posts

Posted - 2005-05-17 : 11:31:32


The value in the table is:
2005-05-05 11:13:41.890

This convert function:

Convert(char(10),tbl_WhiteCode.dteExportTimeStamp,100)

returns:

Syntax error converting the varchar value '05/05/2005' to a column of data type int.;

however, This convert function:

Convert(char(10),tbl_WhiteCode.dteExportTimeStamp,112)


returns:
20050505


What I need to have returned is 05/05/2005. I thought using the datatype 101, I would get 05/05/2005, but I get a syntax error.
Using the datatype 112 is the only way I get a return value. Every other datatype returns a syntax error.



X002548
Not Just a Number

15586 Posts

Posted - 2005-05-17 : 13:01:41
post the table ddl and some sample data

Brett

8-)
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-05-17 : 13:19:27
That's not the clause that is causing the problem.
You have something like

select 1 + Convert(char(10),tbl_WhiteCode.dteExportTimeStamp,100)
(probably not as obvious as this)
And it is trying to convert the string to an int
20050505 will implcitly convert to an int so you don't get an error
05/05/2005 doesn't so you get the error

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -