Reg Exp
Web Design
Notes Client
Rolling 12 Month Selection List
In a recent project, we had a need to have a month picker. The users wanted to default the month to the current month and have the radio button list be in order, starting with the current month. So, for example, in July the users would see "July" first, then "August", and so on, through "December", then "January" and so on through "June". There would always be 12 months shown, starting with the current month and ending with last month.

It was surprisingly simple to implement this. It took just a couple lines of code:

Months := "January" : "February" : "March" : "April" : "May" : "June" : "July" : "August" : "September" : "October" : "November" : "December";
List := Months : Months;
@Subset(@Subset(List; 11+@Month(@Today)); -12)

First, build a list of all the months. Then, double that list (so it goes "January", ..., "December", "January", ..., "December"). Then take a subset of that list containing the 12 months starting where we want. If it's January (month 1), then take the first 12 entries ("January" through "December") and then take the last 12 entries of that list (which will take all of them). If it's June (month 6), then take the first 17 entries ("January" through "May") and then the last 12 entries of that list ("June" through "May").