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 | | | | re: Number of days since 01/01/0000
' 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:upzOEra9DHA.2460@TK2MSFTNGP09.phx.gbl...[color=blue]
> 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
>
>[/color] | | | | re: Number of days since 01/01/0000
"Scott Kilbourn" <skilbourn@NO_SPAM_PLEASE.appliedsystems.com>
schrieb[color=blue]
>
> 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.[/color]
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 | | | | re: Number of days since 01/01/0000
I don't think that this works for 01/01/0000 though.
"Adrian Forbes [ASP MVP]" <sorry@noemail.zzz> wrote in message
news:%236cKY6a9DHA.2752@TK2MSFTNGP09.phx.gbl...[color=blue]
> ' 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:upzOEra9DHA.2460@TK2MSFTNGP09.phx.gbl...[color=green]
> > Hi,
> >
> > Does anyone know how to accurately calculate the number of days that[/color][/color]
have[color=blue][color=green]
> > elapsed since 01/01/0000? I'd appreciate any help anyone could give me.
> >
> > Thanks
> >
> >[/color]
>
>[/color] | | | | re: Number of days since 01/01/0000
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:uiR1bBb9DHA.2432@TK2MSFTNGP09.phx.gbl...[color=blue]
> "Scott Kilbourn" <skilbourn@NO_SPAM_PLEASE.appliedsystems.com>
> schrieb[color=green]
> >
> > 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.[/color]
>
> The Datetime type supports values only > 01/01/0001. Let's assume year 0[/color]
had[color=blue]
> 365 days.....
>
>
> MsgBox(Date.Today.Subtract(#12:00:00 AM#).Days + 365)
>
> - or -
>
> Const TicksPerday As Long = &HC92A69C000
> MsgBox((Date.Today.Ticks \ &HC92A69C000) + 365)[/color]
Technically, there is no year 0.
3 BC, 2 BC, 1 BC, 1, 2, 3, 4...
Erik | | | | re: Number of days since 01/01/0000
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:eB6roCb9DHA.3404@TK2MSFTNGP09.phx.gbl...[color=blue]
> I don't think that this works for 01/01/0000 though.
>
> "Adrian Forbes [ASP MVP]" <sorry@noemail.zzz> wrote in message
> news:%236cKY6a9DHA.2752@TK2MSFTNGP09.phx.gbl...[color=green]
> > ' 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:upzOEra9DHA.2460@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > Hi,
> > >
> > > Does anyone know how to accurately calculate the number of days that[/color][/color]
> have[color=green][color=darkred]
> > > elapsed since 01/01/0000? I'd appreciate any help anyone could give[/color][/color][/color]
me.[color=blue][color=green][color=darkred]
> > >
> > > Thanks
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Number of days since 01/01/0000
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:
[color=blue]
>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
>[/color] | | | | re: Number of days since 01/01/0000
"Erik Frey" <eriksjunk@hotmail.com> schrieb[color=blue]
> Technically, there is no year 0.
>
> 3 BC, 2 BC, 1 BC, 1, 2, 3, 4...[/color]
Ah, I forgot because it's a long time ago. :)
--
Armin | | | | re: Number of days since 01/01/0000
Hi Erik,
I hope that Jon Skeet does not see this,
[color=blue]
> Technically, there is no year 0.
>[/color]
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 | | | | re: Number of days since 01/01/0000
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.
<rlucas@programmer.net> wrote in message
news:25l5305cl6l88qp8fen62pgd75brhp9bva@4ax.com...[color=blue]
> 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[/color]
your[color=blue]
> code" as for a school project I might be able to dig up some of my old[/color]
code.[color=blue]
>
> Rich Lucas
>
>
> On Tue, 17 Feb 2004 17:07:03 -0600, "Scott Kilbourn"
> <skilbourn@NO_SPAM_PLEASE.appliedsystems.com> wrote:
>[color=green]
> >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
> >[/color]
>[/color] | | | | re: Number of days since 01/01/0000
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$Fy86z9DHA.2644@TK2MSFTNGP11.phx.gbl...[color=blue]
> 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[/color]
number[color=blue]
> of days stored in this program's database.
>
> <rlucas@programmer.net> wrote in message
> news:25l5305cl6l88qp8fen62pgd75brhp9bva@4ax.com...[color=green]
> > Are you translating from Julian to Gregorian calendar (14 day[/color][/color]
difference)?[color=blue][color=green]
> >
> > .NET has Calendar objects that will do this for you . If you need to[/color][/color]
"show[color=blue]
> your[color=green]
> > code" as for a school project I might be able to dig up some of my old[/color]
> code.[color=green]
> >
> > Rich Lucas
> >
> >
> > On Tue, 17 Feb 2004 17:07:03 -0600, "Scott Kilbourn"
> > <skilbourn@NO_SPAM_PLEASE.appliedsystems.com> wrote:
> >[color=darkred]
> > >Hi,
> > >
> > >Does anyone know how to accurately calculate the number of days that[/color][/color][/color]
have[color=blue][color=green][color=darkred]
> > >elapsed since 01/01/0000? I'd appreciate any help anyone could give[/color][/color][/color]
me.[color=blue][color=green][color=darkred]
> > >
> > >Thanks
> > >[/color]
> >[/color]
>
>[/color] |  | Similar Visual Basic .NET bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,419 network members.
|