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

SmallDateTime Wowes

Status
Not open for further replies.

Wholsea

Programmer
Jun 16, 2004
138
US
Try the following queries:

--first validate that we have a valid date object
select isdate('18560311')

--Lets see what it looks like in datetime format
select cast('18560311' as datetime)

--Woops, doesn't like being converted to smalldatetime
select cast('18560311' as smalldatetime)

Any idea why this date can be converted to a regular date and time, but not a small date and time?

ASP, VB, VBS, Cold Fusion, SQL, DTS, T-SQL, PL-SQL, IBM-MQ, Crystal Reports, Crystal Enterprise
 
If you would have taken the time to look it up in books on line (the documentation that comes with SQl server) then you would see this


datetime
January 1, 1753, through December 31, 9999


smalldatetime
January 1, 1900, through June 6, 2079




Denis The SQL Menace
--------------------
SQL Server Code,Tips and Tricks, Performance Tuning
SQLBlog.com, Google Interview Questions
 
Yeah, I read the bol, but only read the top part (1753) reading is fundamental...



ASP, VB, VBS, Cold Fusion, SQL, DTS, T-SQL, PL-SQL, IBM-MQ, Crystal Reports, Crystal Enterprise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top