Reg Exp
Web Design
Notes Client
Number of days in the month
Sometimes we take things for granted. A "newbie" Notes developer recently asked how to figure out how many days were in the current month using formula language. He even said that he looked on the Breaking Par web site and couldn't find the answer!

Basically, what you want to do is take the current date, adjust back to the first of the current month, adjust one month forward to the first of next month, and then adjust back one day to the last of the current month. The day number of that final adjustment is the number of days in the current month.

There are other ways to accomplish the same thing, with maybe fewer adjustments. But this is pretty straightforward and easy to follow.

StartDate := @Today;
StartOfThisMonth := @Date(@Year(StartDate); @Month(StartDate); 1);
StartOfNextMonth := @Adjust(StartOfThisMonth; 0; 1; 0; 0; 0; 0);
LastOfThisMonth := @Adjust(StartOfNextMonth; 0; 0; -1; 0; 0; 0);

If you're interested in a LotusScript version, this code will do the trick:

Dim StartDateTime As New NotesDateTime("")
StartDateTime.LocalTime = Datenumber(Year(Today), Month(Today), 1)
Call StartDateTime.AdjustMonth(1)
Call StartDateTime.AdjustDay(-1)