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

Converting DATETIME to SMALLDATETIME... 1

Status
Not open for further replies.

BradF

Programmer
Mar 29, 2005
28
0
0
US
I'm needing help writing a query that will convert a DATETIME value into a SMALLDATETIME value and drop any DATETIME values that would cause a SMALLDATETIME overflow error (use NULL instead).

Something like this maybe?

UPDATE TABLE
SET THISDATE = CASE WHEN THISDATE) >= 1/1/1900 OR DATEPART(yyyy, THISDATE) <= 6/1/2079 THEN THISDATE ELSE NULL END
 
Take a look here: faq183-6419

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top