Focal Point
Average Date

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5081057142

August 13, 2007, 05:17 PM
gweller
Average Date
Is there an easy way to calculate the Average date?


WebFOCUS 8201M/Windows Platform
August 13, 2007, 05:19 PM
FrankDutch
yes

TABLE FILE CAR
SUM AVE.SALES
BY COUNTRY
END




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

August 13, 2007, 10:22 PM
Tom Flynn
Please, it's a date calculation request!!!!

The average date between January 1 and January 3 is January 2.

select
to_date(date1, 'yyyy/mm/dd')
+ ((to_date(date2, 'yyyy/mm/dd')
- to_date(date1, 'yyyy/mm/dd')) / 2 )
from dual;

This will calculate the elapsed time between date1 and date2.

In this example, we used an ORACLE dummy table called DUAL.

We'll let Frank convert the above to WebFOCUS....


EDIT: TYPO

This message has been edited. Last edited by: Tom Flynn,


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
August 14, 2007, 01:35 AM
Alan B
gweller

What do you want to infer from 'average date'?

The median (not average) date between January 1 and January 3 is January 2.

The mean date would be an arithmetic average and the mode date, the one that occurs most often.

2007/01/01 - 2 occurrence of date
2007/01/05 - 6 "
2007/01/06 - 8 "
2007/01/07 - 13 "

For this data, very roughly speaking, the median date would be the 2007/01/04, a date where nothing occurred. The Mean date would be 2007/01/06 and the mode date would be 2007/01/07. This is where you get the lies, damn lies and statistics from.

This message has been edited. Last edited by: Alan B,


Alan.
WF 7.705/8.007
August 14, 2007, 03:46 AM
FrankDutch
yes...

I thought DATE was a typo and he ment DATA....




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

August 14, 2007, 03:00 PM
gweller
Sorry, I will be more specific...

I have a table where we store document information by document type. I need a report that will tell me the average date received of the oldest 5 documents for each doc type


WebFOCUS 8201M/Windows Platform
August 14, 2007, 03:55 PM
Darin Lee
just have a sec so I don't have code, but your best bet would be to use date subtraction from a base date for each of the five days, calculate an average of those days elapsed, then add that number back to the base date. This should give you and "Average Date."


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
August 14, 2007, 04:15 PM
FrankDutch
Convert the date to a number (like excel does) calculate the average of these numbers and convert the integer of the result back to a date (use the integer to prevent a date and time result)

To find the oldest five is an other challenge...




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

August 14, 2007, 04:26 PM
mgrackin
gweller,

It sounds like you still need to decide which average you want:

MEAN, MEDIAN, MODE or MIDRANGE?

Here's a web site that discusses the difference of the first three:

http://math.about.com/library/weekly/aa020502a.htm


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
August 14, 2007, 04:30 PM
mgrackin
Here are some basic definitions. All of these are referred to as the Average.

Mean is obtained by summing all elements of the data set
and dividing by the number of elements.

Mode is the data element which occurs most frequently.

Median is the middle element when the data set is arranged in order of magnitude.

Midrange is the arithmetic mean of the highest and lowest data elements.

Got these from:

http://www.andrews.edu/~calkins/math/webtexts/stat03.htm


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
August 15, 2007, 03:50 AM
Tony A
... and rather than converting the date to a number, just use the WebFOCUS internal date format (i.e. YYMD or DMYY) as it is an offset from the base date and is, essentially, a number anyway ...

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
August 15, 2007, 05:09 AM
Alan B
This sounds, to me, like an average age. Then just putting a date onto that age.

As an approach I would, rightly or wrongly, use something like:
DEFINE FILE VIDEOTRK
NEW_DATE/YYMD=TRANSDATE;
NOW_DATE/YYMD='&DATEYYMD';
DAYSOUT/I5= DATEDIF(NEW_DATE,NOW_DATE, 'D');
END
TABLE FILE VIDEOTRK
SUM MIN.NEW_DATE MAX.NEW_DATE MIN.DAYSOUT MAX.DAYSOUT AVE.DAYSOUT
COMPUTE DAYSBACK/I5=(AVE.DAYSOUT)*(-1);
COMPUTE AVE_DATE/YYMD=DATEADD(NOW_DATE, 'D',DAYSBACK);
BY PRODCODE
BY TOTAL LOWEST 5 TRANSDATE
END

I've left all the unnecessary fields in for testing.


Alan.
WF 7.705/8.007
August 17, 2007, 03:24 PM
gweller
Thanks to everyone for their input it Alan's solution worked...


WebFOCUS 8201M/Windows Platform