473,320 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Number of days since 01/01/0000

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
Nov 20 '05 #1
10 5343
' 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" <skilbourn@NO_SPAM_PLEASE.appliedsystems.com> wrote in
message news:up**************@TK2MSFTNGP09.phx.gbl...
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

Nov 20 '05 #2
"Scott Kilbourn" <skilbourn@NO_SPAM_PLEASE.appliedsystems.com>
schrieb

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

Nov 20 '05 #3
I don't think that this works for 01/01/0000 though.

"Adrian Forbes [ASP MVP]" <so***@noemail.zzz> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
' 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" <skilbourn@NO_SPAM_PLEASE.appliedsystems.com> wrote in
message news:up**************@TK2MSFTNGP09.phx.gbl...
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


Nov 20 '05 #4
"Armin Zingler" <az*******@freenet.de> wrote in message
news:ui**************@TK2MSFTNGP09.phx.gbl...
"Scott Kilbourn" <skilbourn@NO_SPAM_PLEASE.appliedsystems.com>
schrieb

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)


Technically, there is no year 0.

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

Erik
Nov 20 '05 #5
Soz, thought you meant 1/1/00 (should read better :)) There is no year 0 so
that date is invalid.

"Scott Kilbourn" <skilbourn@NO_SPAM_PLEASE.appliedsystems.com> wrote in
message news:eB**************@TK2MSFTNGP09.phx.gbl...
I don't think that this works for 01/01/0000 though.

"Adrian Forbes [ASP MVP]" <so***@noemail.zzz> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
' 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" <skilbourn@NO_SPAM_PLEASE.appliedsystems.com> wrote in
message news:up**************@TK2MSFTNGP09.phx.gbl...
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



Nov 20 '05 #6
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
On Tue, 17 Feb 2004 17:07:03 -0600, "Scott Kilbourn"
<skilbourn@NO_SPAM_PLEASE.appliedsystems.com> wrote:
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


Nov 20 '05 #7
"Erik Frey" <er*******@hotmail.com> schrieb
Technically, there is no year 0.

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


Ah, I forgot because it's a long time ago. :)
--
Armin

Nov 20 '05 #8
Cor
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
Nov 20 '05 #9
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.

<rl****@programmer.net> wrote in message
news:25********************************@4ax.com...
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
On Tue, 17 Feb 2004 17:07:03 -0600, "Scott Kilbourn"
<skilbourn@NO_SPAM_PLEASE.appliedsystems.com> wrote:
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

Nov 20 '05 #10
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.
"Scott Kilbourn" <skilbourn@NO_SPAM_PLEASE.appliedsystems.com> wrote in
message news:O$**************@TK2MSFTNGP11.phx.gbl...
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.

<rl****@programmer.net> wrote in message
news:25********************************@4ax.com...
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
On Tue, 17 Feb 2004 17:07:03 -0600, "Scott Kilbourn"
<skilbourn@NO_SPAM_PLEASE.appliedsystems.com> wrote:
Hi,

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


Nov 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Shuffs | last post by:
Could someone, anyone please tell me what I need to amend, to get this function to take Sunday as the first day of the week? I amended the Weekday parts to vbSunday (in my code, not the code...
1
by: penguin732901 | last post by:
I am trying to print a contract for a customer specifying use of their credit card number. For some odd reason the number is being rounded. I checked - it's a text field. On the other hand, I...
6
by: Poewood | last post by:
Is there a way to parse the contents of a textbox into a phone number format? Actually I would like to save the input as a number but display it as a phone number in the typical US format (000)...
4
by: henry | last post by:
Hi all, I'm building a website which provides contents that only work for some browser types and versions. I know I can get most of the client browser information using HttpBrowserCapabilities...
29
by: james | last post by:
I have a problem that at first glance seems not that hard to figure out. But, so far, the answer has escaped me. I have an old database file that has the date(s) stored in it as number of days. An...
4
by: Phil Mc | last post by:
OK this should be bread and butter, easy to do, but I seem to be going around in circles and not getting any answer to achieving this simple task. I have numbers in string format (they are...
5
by: Beemer Biker | last post by:
I cant seem to get that date into any DateTime to make my calculation directly by subtracting "01-01-0000" from "now". After reading this:...
4
by: bretonlais | last post by:
I am creating a scheduling application which will allow users to schedule recurring tasks, e.g., the user can set a task to run (M,T,W) or (M,T,W,TH,F,S) etc. I want binary encode each day of the...
14
by: Tommy Jakobsen | last post by:
Hi. Is there a method in .NET that takes "year" as an argument and returns the total number of weeks in that year? For culture da-DK (Danish). Thanks in advance. Tommy.
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.