dbTalk Databases Forums  

Help problem with date column, loading excel file to mssql table

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Help problem with date column, loading excel file to mssql table in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rick Shaw
 
Posts: n/a

Default Help problem with date column, loading excel file to mssql table - 05-02-2006 , 05:09 PM






Hi, I am trying to load an excel file into a table in mssql and was having
problems. My excel file is in the following format:

ID Name TermDate
1 JB '01/25/2006'
2 Jake ' ---'
3 Smith '05/28/2006'
4 Halal ' ---'

When I try to execute my DTS script (below), I the TermDate column in the
table show NULL.

Any help would be greatly appreciated.

Thank you.

Rick..


Function Main()
DTSDestination("EmpID") = DTSSource("ID")
DTSDestination("Name") = DTSSource("Name")
DTSDestination("TermDate") = DTSSource("TermDate")

dim i_Day
dim i_Month
dim i_Year

If len(DTSSource("Term Date")) = 10 Then
i_Day = Cint(Mid( DTSSource("Term Date") , 4 , 2 ))
i_Month = Cint(Mid( DTSSource("Term Date") , 1, 2 ))
i_Year = Cint(Left(DTSSource("Term Date"), 4))

DTSDestination("TermDate") = DateSerial( i_Year , i_Month ,i_Day )
Else
DTSDestination("TermDate") = Null
End If

Main = DTSTransformStat_OK
End Function




Reply With Quote
  #2  
Old   
Rick Shaw
 
Posts: n/a

Default Re: Help problem with date column, loading excel file to mssql table - 05-02-2006 , 05:12 PM






Sorry the line 'DTSDestination("TermDate") = DTSSource("TermDate")' is
commented out.

Thanks,


"Rick Shaw" <rickshaw888*NOSPAM*@hotmail.com> wrote

Quote:
Hi, I am trying to load an excel file into a table in mssql and was having
problems. My excel file is in the following format:

ID Name TermDate
1 JB '01/25/2006'
2 Jake ' ---'
3 Smith '05/28/2006'
4 Halal ' ---'

When I try to execute my DTS script (below), I the TermDate column in the
table show NULL.

Any help would be greatly appreciated.

Thank you.

Rick..


Function Main()
DTSDestination("EmpID") = DTSSource("ID")
DTSDestination("Name") = DTSSource("Name")
DTSDestination("TermDate") = DTSSource("TermDate")

dim i_Day
dim i_Month
dim i_Year

If len(DTSSource("Term Date")) = 10 Then
i_Day = Cint(Mid( DTSSource("Term Date") , 4 , 2 ))
i_Month = Cint(Mid( DTSSource("Term Date") , 1, 2 ))
i_Year = Cint(Left(DTSSource("Term Date"), 4))

DTSDestination("TermDate") = DateSerial( i_Year , i_Month ,i_Day )
Else
DTSDestination("TermDate") = Null
End If

Main = DTSTransformStat_OK
End Function






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.