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

active x question

Status
Not open for further replies.

swoodring

Programmer
Dec 7, 2000
114
US
I am new to visual basic so this might seem like a simple question. I am trying to take a date field and a time field from an as/400 and put it into a smalldatetime field. When I try to use an activex using just the date field or just the time field I get the correct date or time. But when I try combining them I do not get what I'm expecting the time looks correct but the date is way off. Any ideas would be greatly appreciated. I've included the code I've been using.


Dsrddati = 2001-01-28
Dsrdtime = 10.49.00

Time by itself
Function Main()
DTSDestination("TransactionDate") = cdate(DTSSource("dsrdtime"))
Main = DTSTransformStat_OK
End Function
result = 2/14/01 10:49:00 AM



Date by itself
Function Main()
DTSDestination("TransactionDate") = cdate(DTSSource("dsrddati"))
Main = DTSTransformStat_OK
End Function
result = 1/28/01


Combining both date and time
Function Main()
DTSDestination("TransactionDate") = cdate(DTSSource("dsrddati")) + cdate(DTSSource("dsrdtime"))
Main = DTSTransformStat_OK
End Function
result = 3/16/2102 10:49:00 AM

 
when I do the following I get an error stating type mismatch cdate.

Function Main()
DTSDestination("TransactionDate") = cdate((DTSSource("dsrddati") & DTSSource("dsrdtime")))
Main = DTSTransformStat_OK
End Function


If I just do the concatation part I get the following result.
Function Main()
DTSDestination("TransactionDate") = (DTSSource("dsrddati") & DTSSource("dsrdtime"))
Main = DTSTransformStat_OK
End Function
result = 1/28/0112/14/01 10:49:00 AM.

any other suggestions?


 
Well, you tried what I had in mind. In such cases (when DTS is my only option), I result to the following:

* import each (date, time) into separate columns in a staging table (i.e. columns datetemp, timetemp)

* concatenate them in the insert into the destination, such as:

[tt]insert into MyFinalTable
select col1, col2,..., cast(datetemp + ' ' + timetemp)
from MyStagingTable [tt]
Robert Bradley
Do you have too much money? Visit
 
Actually just tried this and this seems to work. Thanks for your help. Stacy

Function Main()
DTSDestination("TransactionDate") = cdate(DTSSource("dsrddati")) & " " & timevalue(DTSSource("dsrdtime"))
Main = DTSTransformStat_OK
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top