Number of days since 01/01/0000

  • Thread starter Thread starter Scott Kilbourn
  • Start date Start date
S

Scott Kilbourn

Hi,

Does anyone know how to accurately calculate the number of days that have
elapsed since 01/01/0000? I'd appreciate any help anyone could give me.

Thanks
 
' short
Dim days As Integer = Now.Subtract(New Date(2000, 1, 1)).Days

' long
Dim dtDate As New DateTime(2000, 1, 1)
Dim span As TimeSpan = Now.Subtract(dtDate)
Dim days = span.Days
 
Scott Kilbourn said:
Does anyone know how to accurately calculate the number of days that
have elapsed since 01/01/0000? I'd appreciate any help anyone could
give me.

The Datetime type supports values only > 01/01/0001. Let's assume year 0 had
365 days.....


MsgBox(Date.Today.Subtract(#12:00:00 AM#).Days + 365)

- or -

Const TicksPerday As Long = &HC92A69C000
MsgBox((Date.Today.Ticks \ &HC92A69C000) + 365)




--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Armin Zingler said:
The Datetime type supports values only > 01/01/0001. Let's assume year 0 had
365 days.....


MsgBox(Date.Today.Subtract(#12:00:00 AM#).Days + 365)

- or -

Const TicksPerday As Long = &HC92A69C000
MsgBox((Date.Today.Ticks \ &HC92A69C000) + 365)

Technically, there is no year 0.

3 BC, 2 BC, 1 BC, 1, 2, 3, 4...

Erik
 
Soz, thought you meant 1/1/00 (should read better :)) There is no year 0 so
that date is invalid.
 
Are you translating from Julian to Gregorian calendar (14 day difference)?

..NET has Calendar objects that will do this for you . If you need to "show your
code" as for a school project I might be able to dig up some of my old code.

Rich Lucas
 
Hi Erik,

I hope that Jon Skeet does not see this,
Technically, there is no year 0.

For Jon everything starts at 0.

:-)

Do not become angry Jon, just for fun and for this you where the first I had
to think on.

Cor
 
No.

I'm using a program that is seriously lacking in some areas. I wanted to
write a couple of utilities for myself that will make up for some of the
flaws in the program. The dates that I need to be able to read and write
are in this format, so I needed to know how to move between them.

FYI, this is what I came up with that actually matches the dates in the
program.

Dim DateTest As New Date(1, 1, 1)
Dim FutureDate As New Date(CInt(txtYear.Text), CInt(txtMonth.Text),
CInt(txtDay.Text))
MsgBox(DateDiff(DateInterval.Day, DateTest, FutureDate) + 367)

Or...

Dim days As Integer = Now.Subtract(New Date(1, 1, 1)).Days + 367

The +367 is interesting, but this is how I can reliabiliy get to the number
of days stored in this program's database.
 
Scott:

There is little doubt that Rich was simply "confused" by your question and
specifically your use of term "accurately calculate." The calendar has been
adjusted (more than once if memory serves me correctly) ... note that "Oct.
4, 1582 was followed by October 15, 1582"

We (or at least "I") don't know what you are trying to do :-) It's hard to
be of any help in that case.
 
Back
Top