CONVERT to datetime from integer using style 112 - Arithmetic overflow - by Dr3Bob

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 167544 Comments
Status Closed Workarounds
Type Suggestion Repros 0
Opened 7/20/2006 10:52:53 AM
Access Restriction Public


When attempting to CONVERT to datetime from an integer, I get an Arithmetic overflow (e.g. CONVERT( datetime, 19501001, 112)).  Apparently (based on some newsgroup articles) this is because CONVERT is attempting to convert the integer value as the number of days since January 1, 1900.  I cannot find any reference to this conversion in SQL BOL (2000 or 2005).  This should be a footnote under the topic "CAST and CONVERT (Transact-SQL)" in BOL.
Sign in to post a comment.
Posted by Microsoft on 8/11/2006 at 3:44 PM
You could use string instead of integer, e.g., CONVERT( datetime, '19501001', 112). If your input comes as integer, you can convert it to string first and then convert to datetime.