Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Standard Deviation on Date Array 1

Status
Not open for further replies.

TopJack

Programmer
Mar 10, 2001
153
GB
I have a Crystal 9 report that has a running formula that puts together a dynamic array at runtime. The array collects date values. The formula is something like this ..........

Code:
WhilePrintingRecords;
dateVar array demand_dates;
numberVar d;

demand_dates[d] := date({Command.Date});
d := d + 1;


The array will look something like this at the end of the report .............

demand_dates[0]=01/01/2006
demand_dates[1]=01/02/2006
demand_dates[2]=01/03/2006
demand_dates[3]=01/04/2006

At the end of the report I want to work out the variation between the dates, ie the standard deviation.
Ideally I want to use the formula std_demand_date = StdDev(demand_dates). But I get a syntax error because the StdDev function requires a number.

How do I transalate a normal date into a serial number to allow a standard deviation calculation.

An example in Excel would be that the 01/01/2006 date is actually stored as the number 38718. Which allows a standard deviation calculation.

Any ideas how to do this in Crystal?
 
You can use the following to convert the date to a number:

datediff("d",date(1899,12,30),{command.date})

This can, in turn, be converted back to a date by using:

datevalue(datediff("d",date(1899,12,30),{command.date}))

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top