Serial Date

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

What is the easiest way to convert serialdate (like excel has) into real
date in VB.NET?


Thank You


Peter
 
Peter said:
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
 
Armin Zingler said:
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
 
Peter said:
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
 
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.
 
Back
Top