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 :)
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 :)
ASKER
I need the datetime as one object
so a date
and a time
into a vb.net datetime
so a date
and a time
into a vb.net datetime
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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. :)
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. :)
A return value indicates whether the conversion succeeded or failed.
Dim lDateValue As Date
If Date.TryParse(dr("Date").T
....
End