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; -@Day(next_month); 0; 0; 0);

The -@Day(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.

This was first published in September 2001

Dig deeper on Lotus Notes Domino Administration Tools

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close