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!

How do I use DTS to convert a Date from float in YYYYMMDD 1

Status
Not open for further replies.

jpittawa

Programmer
Oct 2, 2002
51
US
The source is LeasePlus, which is BTrieve. The date fields are floats in YYYYMMDD format, e.g.19990601. I need to use DTS to put some LeasePlus tables into SQL Server 7.0 for reporting. I would like to convert the dates into the Microsoft DateTime format in a DTS package that runs nightly. How do I do that?
 
Hi,

To do this, you will need to do an ActiveX transform with the following script added in below the main section of the code...


Function xformdate (pass_date)
dim temp_date 'date to be passed back
dim d 'day
dim m 'month
dim y 'year


'set the day, month and year sections of the date and put together the final date
d = mid(pass_date, 7, 2)
m = mid(pass_date, 5, 2)
y = mid(pass_date, 1, 4)

temp_date = y & "/" & m & "/" & d

'check that the date being passed back is a real date and that the original date field was not 0
if IsDate(temp_date) = false then temp_date = ""
if pass_date = "0" then temp_date = ""

'pass the corrected date back
xformdate = temp_date
end function



To use the function, call it from the main section of the code...

DTSDestination("sql datatime field") = xformdate(DTSSource("BTrieve numeric field"))




I have found this bit of code very useful in preparing datetime fields. The check and default value may need to be modified, depending on your particular situation.


Hope it helps.

Kevin
**************************************************************
Rock is Dead (Long Live Paper and Scissors)**************************************************************
 
quatermass (Kevin), thanks. I'll give this a try.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top