Groups | Blog | Home
all groups > sql server data mining > march 2004 >

sql server data mining : Datetime Minimum Date values


Roger B
3/17/2004 8:44:17 AM

I've got a linked server setup to DB2, and some of the
date fields in the DB contain 1/1/0001 values.

When I attempt to select that field, I get an error

Server: Msg 8114, Level 16, State 8, Line 1
Error converting data type DBTYPE_DBTIMESTAMP to datetime.

I assume since valid dates ranges in SQL are from
January 1, 1753 through December 31, 9999, this would be
what's causing this.

How do I get around this, because I have to have these
date values back from the DB2. I tried convert on the
field and I get the same error.

Thanks

Jacco Schalkwijk
3/18/2004 1:39:25 PM
Check with the people responsible for the DB2 database wath the business
meaning is of the 1/1/0001 date. I assume it doesn't mean that your company
has been around since emporer Augustus. Once you have found out what the
meaning is, you can replace them with an appropriate value, maybe NULL or
1/1/1900 using a CASE statement in your select:
CASE datefield WHEN '1/1/0001' THEN NULL ELSE CONVERT(DATETIME, datefield,
103) END AS date_column

--
Jacco Schalkwijk
SQL Server MVP


[quoted text, click to view]

(allirajan NO[at]SPAM hotmail.com)
4/1/2004 11:51:22 PM
hi roger,

to overcome this try the below code and let me know :

SELECT *
FROM OPENQUERY(test_to_oracle, 'select to_char(date_field,''dd/mm/yyyy'') from table_name')

note :
linkedservername = test_to_oracle

allirajan



**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
SqlJunkies User
11/19/2004 9:36:24 AM
You da Man! that OPENQUERY deal worked like a charm. some knuckle head entered a Start_date of 1196 in our database.

---
Posted using Wimdows.net NntpNews Component -

AddThis Social Bookmark Button