MONTH
Syntax
MONTH ({Date})
Description
The MONTH function returns the month of Date. If Date is omitted, the function returns the month of the calculation date.
Returns
The month of Date. If Date is omitted, the function returns the month of the calculation date.
Example
If A = 2004/03/15 and
B = 2005/06/22, MONTH(A) returns 3 and MONTH(B) returns 6.
Now suppose that an
analytic model contains a data cube called MONTH_EXAMPLE that uses
a dimension called MONTHS and has the formula MONTH_EXAMPLE = MONTH(
). Because the argument is omitted, MONTH returns
the month for each date in the MONTHS dimension.
Following is a useful example of the MONTH function. Suppose that you define a data cube called MONTHLY_SALES that uses a dimension called MONTHS. You want to calculate the average sales for each month of the year. In other words, you want to know the average sales for the first month of each year, the average sales for the second month of each year, and so on. To do this, create a dimension called MONTH_NUM that contains members numbered 1 to 12. Then define a data cube called AVG_SALES_BY_MONTH that uses the MONTH_NUM dimension. Finally, enter the following formula for the AVG_SALES_BY_MONTH cube:
DAVG(MONTHS, MONTHLY_SALES, MONTH( ) = MEMBER(MONTH_NUM))
See the entries for DAVG and MEMBER if you are unfamiliar with these functions. For each MONTH_NUM member in AVG_SALES_BY_MONTH, the formula averages all Monthly Sales for which the month of the year equals the index of the MONTH_NUM member. Thus, if the analytic calculation engine calculates the fifth MONTH_NUM member for AVG_SALES_BY_MONTH, it averages the sales for the dates 2004/05/03, 2004/05/04, and 2004/05/05, because these are the dates for which the MONTH( ) function returns 5.