# Date Calculation - WW - ERROR IN FORMULA

#### 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

#### donbryant

##### Active Member
Title: World Writer - Subtract two dates to get the number of days
difference
Abstract: How to get the number of days between two dates stored in julian
format
Product World
Suite Technical
Release A5.2 - A8.1
Document ID WST-99-0208
Date Created 11/08/1999

If you have online support this document solves your problem. Go to the knowledge garden and do a search for WST-99-0288.
It works.

Don Bryant, MIS Director, mailto:[email protected]
Amalie Oil Company
1601 McCloskey Blvd.
Tampa Fl, 33605

Don Bryant, MIS Director
Phone 813-248-1988 ext 124
Fax 813-248-1488

#### ehassman

##### Member
<html><DIV>

</P>
<DIV></DIV>

What is the error?</P></DIV>

To get the difference between two dates, enter the starting date and the ending date the program will return the difference between the dates. </P>
<DIV></DIV>

Look at the program X0035 there is are descriptions of how to set up the different s<SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">cenarios</SPAN>, and there are also examples. </P>
<DIV></DIV>

Ed Hassman</P>
<DIV></DIV>

[email protected]

</P>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>>From: donbryant <[email protected]>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>>To: [email protected]
<DIV></DIV>
<DIV></DIV>>Subject: RE: Date Calculation - WW - ERROR IN FORMULA
<DIV></DIV>
<DIV></DIV>>Date: Mon, 19 Mar 2001 06:22:17 -0800 (PST)
<DIV></DIV>
<DIV></DIV>>
<DIV></DIV>
<DIV></DIV>>Title: World Writer - Subtract two dates to get the number of days
<DIV></DIV>
<DIV></DIV>>difference
<DIV></DIV>
<DIV></DIV>>Abstract: How to get the number of days between two dates stored in julian
<DIV></DIV>
<DIV></DIV>>format
<DIV></DIV>
<DIV></DIV>>Product World
<DIV></DIV>
<DIV></DIV>>Suite Technical
<DIV></DIV>
<DIV></DIV>>Release A5.2 - A8.1
<DIV></DIV>
<DIV></DIV>>Document ID WST-99-0208
<DIV></DIV>
<DIV></DIV>>Date Created 11/08/1999
<DIV></DIV>
<DIV></DIV>>
<DIV></DIV>
<DIV></DIV>>
<DIV></DIV>
<DIV></DIV>>If you have online support this document solves your problem. Go to the knowledge garden and do a search for WST-99-0288.
<DIV></DIV>
<DIV></DIV>>It works.
<DIV></DIV>
<DIV></DIV>>
<DIV></DIV>
<DIV></DIV>>Don Bryant, MIS Director, mailto:[email protected]
<DIV></DIV>
<DIV></DIV>>Amalie Oil Company
<DIV></DIV>
<DIV></DIV>>1601 McCloskey Blvd.
<DIV></DIV>
<DIV></DIV>>Tampa Fl, 33605
<DIV></DIV>
<DIV></DIV>>
<DIV></DIV>
<DIV></DIV>>
<DIV></DIV>
<DIV></DIV>>
<DIV></DIV>
<DIV></DIV>>Don Bryant, MIS Director
<DIV></DIV>
<DIV></DIV>>Phone 813-248-1988 ext 124
<DIV></DIV>
<DIV></DIV>>Fax 813-248-1488
<DIV></DIV>
<DIV></DIV>>
<DIV></DIV>
<DIV></DIV>>--------------------------
<DIV></DIV>
<DIV></DIV>>To view this thread, visit the JDEList forum at:
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>>+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
<DIV></DIV>
<DIV></DIV>>This is the JDEList World Mailing List.
<DIV></DIV>
<DIV></DIV>>Archives and information on how to SUBSCRIBE, and
<DIV></DIV>
<DIV></DIV>>UNSUBSCRIBE can be found at http://www.JDELIST.com
<DIV></DIV>
<DIV></DIV>>+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
<DIV></DIV>
<DIV></DIV>>
<DIV></DIV>