DAY
Syntax
DAY ({Date})
Description
The DAY function returns the day of the specified date. If Date is omitted, DAY returns the day of the calculation date.
Example
If A = 2004/03/15 and B = 2005/06/22, then DAY(A) returns 15 and DAY(B) returns 22.
Now suppose an analytic model contains a data cube called DAY_EXAMPLE that uses a dimension called DAYS, and contains the formula DAY_EXAMPLE = DAY( ). Because the argument is omitted, DAY returns the day for each date in the DAYS dimension.
Following is a more useful example of the DAY function: suppose you define a data cube called DAILY_RECEIPTS that uses a dimension called DAYS. You want to calculate the average receipts for each day of the month. In other words, you want to know the average receipts for the first day of each month, the average receipts for the second day of each month, and so on. To do this, create a dimension called DAY_NUM that contains members numbered 1 to 31. Then define a data cube called AVG_RECEIPTS_BY_DAY that uses the DAY_NUM dimension. Finally, enter the following formula for the AVG_RECEIPTS_BY_DAY data cube:
DAVG(DAYS, DAILY_RECEIPTS, DAY( ) = MEMBER(DAY_NUM))
For each DAY_NUM member in AVG_RECEIPTS_BY_DAY, the formula averages all DAILY_RECEIPTS where the day of the month equals the index of the DAY_NUM member. Thus, if the program is calculating the fifth DAY_NUM member for AVG_RECEIPTS_BY_DAY, it averages the receipts for the dates 2005/01/05, 2005/02/05, 2005/03/05, 2005/04/05, and so on, because these are the dates where the DAY( ) function returns 5.
Related Topics