Handling null dates

Hello,
I 'm having a rough time handling null dates.  I'm pulling data via odbc with a Script Component.  I keep getting a Specified Cast is not valid everytime it comes
across a date in the source database that's null. For example, I have a quote table with ClosedDate. If the quote is not closed, this field is null.
I've tried using IsDBNull, and IsDate in an if statement to catch it and set it to 01/01/1900 if the date was null, but it seems to ignore them.  
Any help would be greatly appreciated.
Thanks
Chad
LVL 2
ChadMarshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

QPRCommented:
Can you do this within the select?

select isNull(ClosedDate,'01/01/1900') as ClosedDate
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChadMarshAuthor Commented:
Thanks for the reply.
The database I'm pulling the data from is a Progress database that only supports SQL-89 so unfortunately, isnull and even ifnull is not an option
0
ChadMarshAuthor Commented:
I found a way around it. Instead of pulling the data in as a Reader, pull it in as a Dataset which then using ISDbNull actually works.
I have to put an if statement on just about every field but it works. So for the dates I use
If IsDBNull(OHedRow.Item(10)) Then
                    .OrderDate = Convert.ToDateTime("01/01/1900")
                Else
                    .OrderDate = OHedRow.Item(10)
                End If
Then I have a clean up procedure once it get into MSSQL that sets all the 01/01/1900 dates back to null
Kind of a round about way, but it works.
Thanks for you response. You seem to be the only what that wanted to respond.
0
ChadMarshAuthor Commented:
I meant to give you the points..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.