How to Convert a DB2 'Date' Datatype to a SQL Server 'DateTime' Dataype?

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Thanks but it has thrown me error. What exactly is this query trying to do?

"SELECT DB2DateColumn FROM DB2Schema.Table"
returns one of the following three formats, depending on your system setting:
2011-12-17
17.12.2011
12/17/2011
Hence, to be sure to have the first form, I used
"SELECT CHAR(DB2DateColumn, ISO) FROM DB2Schema.Table"

Next, since I (apparently wrongly) guessed SQL Server expects a text fragment of the form
"2011-12-17 00:00:00"
as input for a "datetime" entry, I let DB2 append (concat) the last 9 characters.

So adapt where necessary to match your SQL Server locale setting; e.g., if it expects something of the form
"12/17/2011 00:00:00"
use

"SELECT DB2DateColumn FROM DB2Schema.Table"
returns one of the following three formats, depending on your system setting:
2011-12-17
17.12.2011
12/17/2011
Hence, to be sure to have the first form, I used
"SELECT CHAR(DB2DateColumn, ISO) FROM DB2Schema.Table"

Next, since I (apparently wrongly) guessed SQL Server expects a text fragment of the form
"2011-12-17 00:00:00"
as input for a "datetime" entry, I let DB2 append (concat) the last 9 characters.

So adapt where necessary to match your SQL Server locale setting; e.g., if it expects something of the form
"12/17/2011 00:00:00"
use