Manage Learn to apply best practices and optimize your operations.

Last day of a month redux (any location)

A new version of an older script that gathered the last day of a month. This one works anywhere.

A recent tip showed how to calculate the last day of a month. It worked nicely, but unfortunately, only if your date format is dd/mm/yy (UK, I think).

This version works anywhere.

Basic idea: Advance the day into the next month, then go back to the first day of the next month -- and one day further.


start_date := @Today;
next_month := @Adjust(start_date; 0; 1; 0; 0; 0; 0);
last_of_month := @Adjust(next_month; 0; 0; [email protected](next_month); 0; 0; 0);

The [email protected](next_month) actually advances to the last day of the previous month, which is really our start month. Think about it...

start date: July 3, 1968
next month: August 3, 1968
Day of next month: 3
August 3 - 2 days is August 1, but August 3 - 3 days is July 31.

This works no matter what month, no matter what year, no matter what day of the month you start on. Since it doesn't use any text conversion, it doesn't rely on any assumptions as to date format.

Dig Deeper on Lotus Notes Domino Administration Tools

SearchWindowsServer
Search400
  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

SearchDataCenter
SearchContentManagement
Close