Home All Groups Group Topic Archive Search About
Author
16 Mar 2006 6:33 AM
Peter
What is the easiest way to convert serialdate (like excel has) into real
date in VB.NET?


Thank You


Peter

Author
16 Mar 2006 10:53 AM
Armin Zingler
"Peter" <pczurak@nospam.nospam> schrieb
> What is the easiest way to convert serialdate (like excel has) into
> real date in VB.NET?

What is a serial date? Is it a Double, an Integer or what? Does it have a
base date like 1/1/1900? Have a look at the constructors and other members
of the DateTime data type.


Armin
Author
16 Mar 2006 2:17 PM
Peter
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:uDWuWlOSGHA.2156@tk2msftngp13.phx.gbl...
> "Peter" <pczurak@nospam.nospam> schrieb
>> What is the easiest way to convert serialdate (like excel has) into
>> real date in VB.NET?
>
> What is a serial date? Is it a Double, an Integer or what? Does it have a
> base date like 1/1/1900? Have a look at the constructors and other members
> of the DateTime data type.
>
>
> Armin

In VB6 you could do the following

    Dim d As Date
    Dim dbSerial As Double

    d = Now
    dbSerial = d +1
    '
    ' or
    '
    db = 38793.3447800926
    d = dbSerial


How can I do this in .NET
Author
16 Mar 2006 2:54 PM
Armin Zingler
Show quote Hide quote
"Peter" <pczurak@nospam.nospam> schrieb
>
> "Armin Zingler" <az.nospam@freenet.de> wrote in message
> news:uDWuWlOSGHA.2156@tk2msftngp13.phx.gbl...
> > "Peter" <pczurak@nospam.nospam> schrieb
> > > What is the easiest way to convert serialdate (like excel has)
> > > into real date in VB.NET?
> >
> > What is a serial date? Is it a Double, an Integer or what? Does it
> > have a base date like 1/1/1900? Have a look at the constructors
> > and other members of the DateTime data type.
> >
> >
> > Armin
>
> In VB6 you could do the following
>
>    Dim d As Date
>    Dim dbSerial As Double
>
>    d = Now
>    dbSerial = d +1
>    '
>    ' or
>    '
>    db = 38793.3447800926
>    d = dbSerial
>
>
> How can I do this in .NET


Have a look at the members of the DateTime data type. For example:

    dim d, nextday as date

    d = now    'or datetime.now
    nextday = d.AddDays(1)

    d = DateTime.FromOADate(38793.3447800926)

Where do you get the value 38793.3447800926 from?


Armin
Author
17 Mar 2006 8:23 AM
Cerebrus
Hi,

AFAIK, An Excel Serial Date is the number of days since 1-1-1900.

For eg., Excel stores March 17, 2006, as serial number 38793 because it
is 38,793 days after January 1, 1900. The digits after the period in
Peter's example are probably the no. of seconds elapsed in that day.

Excel stores dates as sequential serial numbers so that it can perform
calculations on them. Excel stores January 1, 1900, as serial number 1.


But if the members of the DateTime class have any pre-built conversion
defined, of that I'm not too sure. Maybe Armin (Who, I have noticed, is
our DateTime authority... ;-)) can help here.

Regards,

Cerebrus.