Discussion:
Derived Column to Combine Separate Date and Time Fields into One Field
(too old to reply)
MLightsOut
2010-11-19 17:18:01 UTC
Permalink
Newbie! I have a DT_DBDate field and a DT_DBTime field in my flat
file. How do I write the expression in the derived column to combine
date and time into one field whose data type would be DT_DBTimeStamp?
I have search everywhere but am I am still stuck....

Example Inputs:
Date = 11/12/2010
Time = 16:00:59

Expected Derived Column (add as new column) Result:
2010-11-12 16:00:59.000
Bob Barrows
2010-11-22 14:15:04 UTC
Permalink
Post by MLightsOut
Newbie! I have a DT_DBDate field and a DT_DBTime field in my flat
file. How do I write the expression in the derived column to combine
date and time into one field whose data type would be DT_DBTimeStamp?
I have search everywhere but am I am still stuck....
Date = 11/12/2010
Time = 16:00:59
2010-11-12 16:00:59.000
In the expression editor, expand the Type Cast node in the upper right
pane and scroll down until you get to the date and time casting
functions. Example:

(DT_DBTIMESTAMP)("11/22/2010" + " 13:00:00")
--
HTH,
Bob Barrows
MLightsOut
2010-11-22 14:21:56 UTC
Permalink
Newbie!  I have a DT_DBDate field and a DT_DBTime field in my flat
file.  How do I write the expression in the derived column to combine
date and time into one field whose data type would be DT_DBTimeStamp?
I have search everywhere but am I am still stuck....
Date = 11/12/2010
Time = 16:00:59
2010-11-12 16:00:59.000
Nevermind, I figured it out. In my flat file the DT_DBDate date field
format is "MM/DD/YYYY" and my DT_DBTime time field format is
"HH:mm:SS". My "DateTime" field in my SQL output table is formatted
as smalldatetime. So I created a derived column name called
"ReportDateTime" and used the expression below. Then I mapped the
"ReportDateTime" variable to the "DateTime" field in the OLE DB
destination editor:

SUBSTRING((Dt_WSTR,20)[Date],7,4) + "-" + SUBSTRING((Dt_WSTR,20)[Date],
1,2) + "-" + SUBSTRING((Dt_WSTR,20)[Date],4,2) + " " + (Dt_WSTR,20)
[Time]

Loading...