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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

conversion of char data type to a datetime

Status
Not open for further replies.

peterempson

Technical User
Dec 28, 2004
4
GB
My report uses a sql stored procedure. Works fine in sql 2000 but when adding it to the report receiving the error:

ODBC error:[Mocrosoft][ODBC SQL Server Driver] The conversion of char data type to a datetime data type resulted in an-out of ranged datetime value.

the line in the stored procedure causing the problem is as follows;

INSERT INTO temp_whereabouts VALUES (@pa_number, @street_number, @street_entry,cast(cast(year(@street_entry) as varchar)+'-'+cast(month(@street_entry) as varchar)+'-'+cast(day(@street_entry) as varchar)+' 23:59' as datetime))

any ideas how to fix it?
 
Add this to the beginning of the script and try it.

SET DATEFORMAT YMD

That tells SQLServer how to interpret the incoming date format.

You might also want to check that you are actually inputting it as YMD and not YDM.

-SQLBill
 
Cheers SQLBill,

thats working now in Crystal, your a star!
 
But I don't see his star?
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top