Colin_Hugill
Reputable Poster
Hi all,
Recently two subscribers to the list, DKAZINSKI and SCOTT PARKER contributed
a formula for calculation of elapsed days between two Julian dates in
different years.
I used this formula in an AS/400 Query and found that it yielded incorrect
results. The final step was (depending on the desired result):-
Y1 * 365 + D1 - Y2 * 365 - D2 (this is the
dkazinski version)
Y2 * 365 + D2 - Y1 * 365 - D1 (this the Scott
Parker version)
The correct calculation should be:-
Y1 * 365 + D1 - Y2 * 365 + D2
or Y2 * 365 + D2 - Y1 * 365 + D1
Note the last step should be "plus" not "minus".
Note also that for financial calculations this formula doesn't seem to allow
for leap years. It is fine for what we want. We are comparing supplier
invoice dates against receipt and order dates so one day every leap year
makes no real difference.
Regards...... Colin HUGILL
Colin Hugill
Consultant
Recently two subscribers to the list, DKAZINSKI and SCOTT PARKER contributed
a formula for calculation of elapsed days between two Julian dates in
different years.
I used this formula in an AS/400 Query and found that it yielded incorrect
results. The final step was (depending on the desired result):-
Y1 * 365 + D1 - Y2 * 365 - D2 (this is the
dkazinski version)
Y2 * 365 + D2 - Y1 * 365 - D1 (this the Scott
Parker version)
The correct calculation should be:-
Y1 * 365 + D1 - Y2 * 365 + D2
or Y2 * 365 + D2 - Y1 * 365 + D1
Note the last step should be "plus" not "minus".
Note also that for financial calculations this formula doesn't seem to allow
for leap years. It is fine for what we want. We are comparing supplier
invoice dates against receipt and order dates so one day every leap year
makes no real difference.
Regards...... Colin HUGILL
Colin Hugill
Consultant