Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem searching with date criteria

Status
Not open for further replies.

ashab02

Programmer
Jun 28, 2005
87
GB
Hello
I have a set of data and when I convert the column with no where clause it works fine, the whole set converts successfully.
However when i use a cluase, i.e >= '20080701' then it fails 'Syntax error converting datetime from character string.'

I have the following query:

Code:
select  convert(datetime,t2.data,103)
from table1 t1
inner join table2 t2 on t1.code =t2.code 
where convert(datetime,t2.data,103) >= '2008070'

If you take the where clause off it all converts and brings back rows but as soon as you put the where clause in it fails. I have used different ways of inputting the where clause but with no joy

Anyone got any ideas?
 
This string is not full:

'2008070'

You miss the last digit of the DAY.
That should work:
Code:
select  convert(datetime,t2.data,103)
from table1 t1
inner join table2 t2 on t1.code =t2.code
where t2.data >= '2008070[b]1[/b]'

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top