We help IT Professionals succeed at work.
Get Started

Trouble with Null Dates in Script Component

DFCRJ
DFCRJ asked
on
1,252 Views
Last Modified: 2008-01-09
My SSIS package connects to an AS 400 where the month, day, year is stored as a decimal. I have a script component that combines the three fields into one and converts to date which is then copied over to my sql into a Pricing table and a destination field know as BeginDate.
It works, until it encounters a null value for the date fields and I receive this message
Conversion from string "0/0/0" to type 'Date' is not valid. And I understand that since the values in the fields are blank.
I thought at first to check the source Month field and grab only values > 0 but I'm told there are circumstances where the begin dates are blank for a reason. So I have to grab all the data regardless if the BeginDate has a valid date (this not user input) I'm just copying from db2 to sql.
Here is my script.

  Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
        Dim Pdate As Date
        Pdate = CDate((Row.PRBEGINMO1 & "/" & Row.PRBEGINDA1 & "/" & Row.PRBEGINYR1))
        If IsDate(Pdate) Then
            Row.BeginDate = CDate(Pdate)
        End If
    End Sub

everything I try comes back wrong or all the dates as strange like 1889/01/19.
Thanks for the help
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE