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)
 Syntax error converting character string to smalldatetime da

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-12 : 08:08:58
Ben writes "Why am I receiving this error:
Syntax error converting character string to smalldatetime data type.

I am passing in a varchar(10) "1/12/2005" and receive this error. If I hardcode ''1/12/2005'' it will work but I try adding '' + @I_BeginDate + '' and it doesn't work. Any ideas??

The field datatype in the database is smalldatetime.
--------------------------------

@I_BeginDate varchar(10),

(select count(*) from lnr_ad_detail tor inner join lnr_ad_header bor on tor.ad_header_id = bor.ad_header_id
where bor.created_on between '' + @I_BeginDate + '' and ''1/14/2005'' and tor.vehicle_id = b.vehicle_id and bor.company_id = ' + cast(@I_CompanyID as varchar(20)) + '
and tor.status_code = 1) as car_exists,"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-12 : 08:52:58
You didnot assign date to @I_BeginDate

Replace '' + @I_BeginDate + '' by @I_BeginDate

Madhivanan

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

- Advertisement -