Groups | Blog | Home
all groups > sql server dts > july 2003 >

sql server dts : probably easy trasformation question


dannyw NO[at]SPAM wolfdatasystems.com
7/21/2003 11:34:32 AM
I've got an application that is currently converting date data into a
numeric format, and storing the dates as an int data type in the
database. I'm guessing that, given the language the application was
written in (VB 6), the application is just doing using a cint()
function to do the conversion (which then converts the date into the
number of seconds from midnight Jan 1 1970). The problem is that the
activeX funtion CDate() available with DTS doesn't seem to be capable
of reversing the conversion.

Besides hand coding the math to do the transformation, which I'd
rather not have to do, does anyone know of a way to turn what is an
integer in the database back into a date?

I'm using DTS to move the data out of an operational database and into
a reporting database, and I need the dates to be actual dates for
reporting purposes.

TIA

Allan Mitchell
7/22/2003 7:38:43 AM
OK so say we know that our integer field in a DB is the number of seconds >
1/1/1970 00:00:00

We can simply use the DATEADD function

Say I have a value stored of 1058859422

SELECT DATEADD(ss,1058859422,'19700101')

You can use this in the source query negating the need to use AX

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



[quoted text, click to view]

dannyw NO[at]SPAM wolfdatasystems.com
7/22/2003 9:23:35 AM
This works fantastically!

Thanks.

[quoted text, click to view]
AddThis Social Bookmark Button