Link to home
Start Free TrialLog in
Avatar of bethamsetty
bethamsetty

asked on

How to convert flat file date ("041304") into sql Server date format in DTS

Hi ,
    My client is sending one flat file which will be having one column called date field but in that date is coming like "041304".  But through DTS i want to send it to my SQL Server table like this "13-Apr-2004".  How to translate this ?
   Do you think putting ActiveX script in middle and implement below logic is suggestable ?

                    Dim str
                    str = DTSSource("myDate") ' 041304
                    str = Mid(str, 1, 2) & "-" & Mid(str, 3, 2) & "-" & Mid(str, 5, 2) '04-13-04
                    DTSDestination("myDate")=cdate(str)

Please suggest me good solution in this

Regards
Sridhar.B
ASKER CERTIFIED SOLUTION
Avatar of ewilde
ewilde

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of imran_fast
imran_fast

import the data into temporary table in sql server and then
update the column in the temporary table as

update temptable set flatfiledatecolumns = substring(flatfiledatecolumns , 3,2) + '-' + left(flatfiledatecolumns ,2)+'-20'+right(flatfiledatecolumns ,2)