Board index » delphi » Converting Dates to Julian numerics

Converting Dates to Julian numerics

Does anyone have a routine that can do either of the following?
a) convert a date value to a julian numeric
b) calculate the number of days between two days as an integer

?

Any help is appreciated.

Send replies to rlowery@*nospam*mindspring.com

Re:Converting Dates to Julian numerics

Look into the standard TDateTime object.

Re:Converting Dates to Julian numerics

Rick,

Can't help you with a) (actually, I have the code to do this, but
it's part of our component set, so it wouldn't be fair to our users
that have paid for the set for me to post the code...)

For b):

DaysDiff := Trunc(LaterDate - EarlierDate);

where both LaterDate and EarlierDate are TDateTime values.

Explanation:  Delphi stores dates and times in a Double, where
the integral portion is the number of days since either 12/30/1899
or 01/01/1900 (depending on whether you're using a 32-bit or 16-bit
version of Delphi), and the decimal portion is the time as a fraction
of a 24-hour period.

Ken
--
Ken White

Clipper Functions for Delphi
http://members.aol.com/clipfunc

Quote
Rick Lowery wrote:

> Does anyone have a routine that can do either of the following?
> a) convert a date value to a julian numeric
> b) calculate the number of days between two days as an integer

> ?

> Any help is appreciated.

> Send replies to rlowery@*nospam*mindspring.com

> Kill the *nospam* to reply.

Re:Converting Dates to Julian numerics

Go to http://home.istar.ca/~pjp/source.htm

that'll do what you want.

Quote
David Boudreau <dboudr...@cinergy.com> wrote in message

news:77la0i\$7t\$1@news.iquest.net...
Quote
>Look into the standard TDateTime object.

Re:Converting Dates to Julian numerics

Dont think this is quite correct!
If 1 time was at eg: 1.00am and the other 23:11
you'd lose a day
DaysDiff := Trunc(LaterDate) - Trunc(EarlierDate);
Sorry Ken no disrespect you've helped me many times!
Nick Gabb
Quote
Ken White wrote:

> Rick,

> Can't help you with a) (actually, I have the code to do this, but
> it's part of our component set, so it wouldn't be fair to our users
> that have paid for the set for me to post the code...)

> For b):

> DaysDiff := Trunc(LaterDate - EarlierDate);

> where both LaterDate and EarlierDate are TDateTime values.

> Explanation:  Delphi stores dates and times in a Double, where
> the integral portion is the number of days since either 12/30/1899
> or 01/01/1900 (depending on whether you're using a 32-bit or 16-bit
> version of Delphi), and the decimal portion is the time as a fraction
> of a 24-hour period.

> Ken
> --
> Ken White

> Clipper Functions for Delphi
> http://members.aol.com/clipfunc

> Rick Lowery wrote:

> > Does anyone have a routine that can do either of the following?
> > a) convert a date value to a julian numeric
> > b) calculate the number of days between two days as an integer

> > ?

> > Any help is appreciated.

> > Send replies to rlowery@*nospam*mindspring.com

> > Kill the *nospam* to reply.

Re:Converting Dates to Julian numerics

Nick,

No offense taken... And a great catch! Thanks for correcting my
oversight! :-)

Ken
--
Ken White

Clipper Functions for Delphi
http://members.aol.com/clipfunc

Quote
Nick Gabb wrote:

> Dont think this is quite correct!
> If 1 time was at eg: 1.00am and the other 23:11
> you'd lose a day
> DaysDiff := Trunc(LaterDate) - Trunc(EarlierDate);
> Sorry Ken no disrespect you've helped me many times!
> Nick Gabb

> Ken White wrote:

> > Rick,

> > Can't help you with a) (actually, I have the code to do this, but
> > it's part of our component set, so it wouldn't be fair to our users
> > that have paid for the set for me to post the code...)

> > For b):

> > DaysDiff := Trunc(LaterDate - EarlierDate);

> > where both LaterDate and EarlierDate are TDateTime values.

> > Explanation:  Delphi stores dates and times in a Double, where
> > the integral portion is the number of days since either 12/30/1899
> > or 01/01/1900 (depending on whether you're using a 32-bit or 16-bit
> > version of Delphi), and the decimal portion is the time as a fraction
> > of a 24-hour period.

> > Ken
> > --
> > Ken White

> > Clipper Functions for Delphi
> > http://members.aol.com/clipfunc

> > Rick Lowery wrote:

> > > Does anyone have a routine that can do either of the following?
> > > a) convert a date value to a julian numeric
> > > b) calculate the number of days between two days as an integer

> > > ?

> > > Any help is appreciated.

> > > Send replies to rlowery@*nospam*mindspring.com

> > > Kill the *nospam* to reply.