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

Trying 2 Convert 20060703 to datetime...Im Getting an Error

Status
Not open for further replies.

jojo79

Programmer
Oct 11, 2006
40
US
I keep getting the following error.

Server: Msg 8115, Level 16, State 2, Line 3
Arithmetic overflow error converting expression to data type datetime.


Code:
DECLARE @i int
SELECT @i = 20060703
SELECT convert(varchar, convert(datetime, @i), 101) AS "Formatted Int"
 
Try converting to varchar instead.

Code:
DECLARE @i [!]varchar(8)[/!]
SELECT @i = [!]'[/!]20060703[!]'[/!]

SELECT convert(varchar, convert(datetime, @i), 101) AS "Formatted Int"

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top