Home All Groups Group Topic Archive Search About

Converting OLE Automation Dates back into regular date/time?

Author
8 Jun 2006 4:58 PM
TofuTheGreat@gmail.com
I'm using "Now.ToOADate" for a record timestamp in a small database app
(it's what I want to do so don't try to disuade me ;-D).

Anyway.  I store the value of Now.ToOADate in a string field in the
database (16 character field on a SQL server to be exact).  Is there a
way of converting the text value from that field back into a readable
date/time?

For example if a date is stored in the 16 character field as the OLE
Automation format "38876.4941902894" then what do I need to do to work
it backward to get a regular date/time format (i.e. human readable) in
my VB.Net application?

I've been Googling for the technique but I don't know how to word my
search query so I haven't found anything useful.

Author
8 Jun 2006 6:38 PM
Oenone
TofuTheGr***@gmail.com wrote:
> Anyway.  I store the value of Now.ToOADate in a string field in the
> database (16 character field on a SQL server to be exact).  Is there a
> way of converting the text value from that field back into a readable
> date/time?

\\\
    newDate = DateTime.FromOADate(CDbl(yourString))
///

HTH,

--

(O)enone
Author
8 Jun 2006 6:42 PM
TofuTheGreat@gmail.com
Oenone wrote:
Show quoteHide quote
> TofuTheGr***@gmail.com wrote:
> > Anyway.  I store the value of Now.ToOADate in a string field in the
> > database (16 character field on a SQL server to be exact).  Is there a
> > way of converting the text value from that field back into a readable
> > date/time?
>
> \\\
>     newDate = DateTime.FromOADate(CDbl(yourString))
> ///
>
> HTH,
>
> --
>
> (O)enone

HAHA I was just coming back to say "NM" I found a reference to the
FromOADate() in another post and looked it up.  So dteStoredDate =
DateTime.FromOADate(strStoredDate) worked like a charm!

Thanks (O)enone!