Link to home
Start Free TrialLog in
Avatar of spinalogic
spinalogic

asked on

Convert OLE date, OLE time to a datetime object

Hey guys, I'm importing data from a foxpro database into Sql Server 2005 using vb.net.
I have two database columns, a date, and a time, which I need to convert (SAFELY) to a .net DateTime object.

I was thinking of just directly equating the DateTime = dr("Date")
then doing a parse of the time.tostring to correctly obtain the time information.

Is this the best way to do this, or have I missed a good little function for this?  I'm watching this like a hawk :)
Avatar of ericwong27
ericwong27
Flag of Singapore image


 A return value indicates whether the conversion succeeded or failed.
 Dim lDateValue As Date
 If Date.TryParse(dr("Date").ToString, lDateValue) = False Then
    ....
 End

Avatar of spinalogic
spinalogic

ASKER

I need the datetime as one object
so a date
and a time
into a vb.net datetime
ASKER CERTIFIED SOLUTION
Avatar of ericwong27
ericwong27
Flag of Singapore image

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
Didn't know you could do the parameter stuff in VB for strings. I'm from a Java/C background.  Cheers for a great answer.

We're reverse engineering a database and the idiots stored the time a freaking DECIMAL.  Hence my problem and asking for help, but you certainly did answer the question hence obtaining points.  :)