cancel
Showing results for 
Search instead for 
Did you mean: 

Error in converting character string to smalldatetime data type

01-02-2009 11:14 PM
475 views 2 comments
0 Likes
SAP Managed Tags
Subscribe

I've installed SQL Server 2000 on my new laptop and Crystal Report XI, out of sudden, the Crystal Report to certain view can't run and I got the following error:

Details: 22007 [Microsoft][ODBC SQL Server Driver][SQL SERVER]Syntax Error cnverting character string to smalldatetime data type.

Any suggestions?

Hannah

0 Likes

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Likes

Can you post the code that you are using ?

That would help us to provide any suggestions.

Former Member
0 Likes

Here is the view the err is complaining about:

SELECT TOP 100 PERCENT Cur.Closed_Month, Cur.Closed_Year, Cur.Incidents_Closed, Prev.Incidents_Closed AS PrevIncidents_Closed,

YrAgo.Incidents_Closed AS YearIncidents_Closed

FROM (SELECT Closed_Month, Closed_Year, Incidents_Closed

FROM dbo.Incidents_Closed) Cur INNER JOIN

(SELECT Month(CONVERT(datetime, CAST(closed_month AS varchar) + '/01/' + CAST(closed_year AS varchar), 101) + 32) AS PrevMonth,

year(CONVERT(datetime, CAST(closed_month AS varchar) + '/01/' + CAST(closed_year AS varchar), 101) + 32) AS PrevYear,

Incidents_Closed

FROM dbo.Incidents_Closed) Prev ON Cur.Closed_Month = Prev.PrevMonth AND Cur.Closed_Year = Prev.PrevYear INNER JOIN

(SELECT Month(CONVERT(smalldatetime, CAST(closed_month AS varchar) + '/01/' + CAST(closed_year AS varchar), 101) + 366) AS PrevMonth,

year(CONVERT(smalldatetime, CAST(closed_month AS varchar) + '/01/' + CAST(closed_year AS varchar), 101) + 366) AS PrevYear,

Incidents_Closed

FROM dbo.Incidents_Closed) YrAgo ON Cur.Closed_Month = YrAgo.PrevMonth AND Cur.Closed_Year = YrAgo.PrevYear

What confused me is that it works fine with my previous laptop. I wonder if there is any patch in Crystal Report or SQL server that used to support certain functions but not support them anymore....

Thanks

Hannah