Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

convert a datetime to smalldatetime

984 views
Skip to first unread message

sparks

unread,
May 14, 2012, 1:31:03 PM5/14/12
to
Is there any way to do this.
I checked and all my datetimes are > 1/1/1900 so that is not the
problem.

I do not know how to do this. Just for a test I I even converted the
datetime to date but it didnt' work either.

Erland Sommarskog

unread,
May 14, 2012, 2:28:48 PM5/14/12
to
It's utterly unclear what you want to do. I make a guess that you want to
change the data type of a table column. Try:

ALTER TABLE tbl ALTER COLUMN col smalldatetime NOT NULL

If that does not help, please be more specific, and include any
error message you get.


--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

sparks

unread,
May 14, 2012, 2:44:24 PM5/14/12
to
sorry this is exactly what I tried


ALTER TABLE tblCustomerInformation ALTER COLUMN DateOfIssue
smalldatetime NULL

datetime conversion error
Msg 242, Level 16, State 3, Line 3
The conversion of a datetime data type to a smalldatetime data type
resulted in an out-of-range value.
The statement has been terminated.


date conversion error
Msg 242, Level 16, State 3, Line 3
The conversion of a date data type to a smalldatetime data type
resulted in an out-of-range value.

I have tried this with datetime and date in the DateOfIssue column
both times I get the same error

I checked to make sure none of these dates where less than 1/1/1900
and the oldest record is 7/15/2001


Erland Sommarskog

unread,
May 14, 2012, 4:25:59 PM5/14/12
to
And SELECT MAX(datetimecol) returns?

sparks

unread,
May 15, 2012, 7:44:17 AM5/15/12
to

THANK YOU so much.

I just never thought of looking for that.

lets see in one year they have clients from 2050 to 9999
9 records out of 236

and one from 0916 lol



On Mon, 14 May 2012 22:25:59 +0200, Erland Sommarskog
<esq...@sommarskog.se> wrote:

>SELECT MAX(datetimecol)
0 new messages