#MONTHROUND
Rounds a date to the start of an n-month period.
Syntax:
n #MONTHROUND date
The left operand, n, may be positive or negative; its absolute value specifies the length of the rounding interval (in months) and should be one of the following:
12 - annual (round to the beginning of a year)
6 - semi-annual (round to the beginning of a six-month period)
3 - quarterly (round to the beginning of a quarter)
1 - monthly (round to the beginning of a month)
(Intervals of 2 and 4 months are also allowed, but are less useful.)
If n is positive, the date is advanced to the start of the next period. If n is negative, the date is shifted back to the start of the current period. In either case, if the date already falls at the start of a rounding period, it is returned unchanged.
Rounding periods are aligned on a calendar basis. For example, the quarterly periods start on 1/1, 4/1, 7/1, and 10/1. You can shift the alignment of periods by subtracting an offset from the dates (using #DATEMINUS), applying #MONTHROUND, then adding the offset back (using #DATEPLUS). See the example below.
Examples:
6 #MONTHROUND 3/3/2000 equals 7/1/2000
-6 #MONTHROUND 3/3/2000 equals 1/1/2000
1 #MONTHROUND 7/4/2000 equals 8/1/2000
-1 #MONTHROUND 7/4/2000 equals 7/1/2000
1 #MONTHROUND 7/1/2000 equals 7/1/2000
-1 #MONTHROUND 7/1/2000 equals 7/1/2000
Period shifting example:
Round semi-annually, but shift the periods by four months so that instead of starting at 1/1 and 7/1 they start at 5/1 and 11/1:
[ 6 #MONTHROUND (8/14/2000 #DATEMINUS 4m)] #DATEPLUS 4m equals 11/1/2000
[-6 #MONTHROUND (8/14/2000 #DATEMINUS 4m)] #DATEPLUS 4m equals 5/1/2000
Related operators:
-1 #MONTHROUND date is the same as #BEGMTH date.
1 #MONTHROUND date is the same as #NEXTBEGMTH date.