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.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-09-20 : 07:16:01
|
Sharon writes "This is my sql statement:select Patcht.Cpldat, Convert(datetime, DocAssRsp.Val) AssCompDate, Patcht.Credat, from Patcht with (nolock)join Entid as Entidprs with (nolock) on Entidprs.Entsys = Patcht.Autprssys join Entid as Entidpat with (nolock) on Entidpat.Entsys = Patcht.Patsys join Enc with (nolock) on Patcht.Admsys = Enc.Admsys join Orgstr with (nolock) on Enc.Orgsys = Orgstr.Orgsys join Docass with (nolock) on Patcht.Docsys = Docass.Docsys join Vtfdoc with (nolock) on Docass.Asssys = Vtfdoc.Docid left join DocAssRsp with (nolock) on PatCht.DocSys = DocAssRsp.DocSysWhere Patcht.Doctyp = 'AS' and Enc.OrgSys in (21, 49) and ((convert(datetime,docassrsp.val) is not null and (convert(datetime,docassrsp.val) between '07/02/06' and '08/30/06')) or (convert(datetime,docassrsp.val) is null and (patcht.credat between '07/02/06' and '08/30/06'))) and cpldat is not null and Enc.Epsid in ('00003199','00000652')The statement runs successfully if I leave out the last condition in the where clause - and Enc.Epsid in ('00003199', '00000652'). Enc.Epsid is varchar(20). Why am I getting a date coversion error when I include this part of the where? It isn't a datetime field. All of the date conversions work as long as I leave off the Enc.Epsid part of the where." |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-09-20 : 07:58:47
|
Check out all the Fields values which you are converting to Datetime for Enc.Epsid - '00003199' and '00000652' - There may be some varchar values which are creating problems for conversion !Harsh AthalyeIndia."Nothing is Impossible" |
|
|
|
|
|