Next Month's Date

(I still can’t seem to get blog comments to work right for DeveloperWorks. Either I’m not signed in and all the page content works (but I can’t comment), or I sign in and the navigation panes don’t load and I sometimes get server errors with “request too large”, possibly owing to the 67 (!) cookies that developerworks is loading).

In your related blog posting at https://www.ibm.com/developerworks/community/blogs/e9d21113-aa93-467e-ac77-a0d20a21eaec/entry/November_1_2018_at_10_33_40_AM?lang=en you query for “the last day of any given month”, with the complication that months have different numbers of days. You ended up at

q: (day_of_month 1 & it + (length of it - day)) of current month_and_year
A: Fri, 30 Nov 2018

I have an alternative approach, related to your maintenance window approach - the last day of any given month, is the day before the first day of the following month

// Get now (for reference only)
q: now 
A: Tue, 18 Dec 2018 21:36:07 -0600
T: 0.030 ms
I: singular time

// Get the first day of this month
q: day_of_month 1  & current month_and_year
A: Sat, 01 Dec 2018
T: 0.043 ms
I: singular date

// the last day of this month, is the day before the first day of the next month
q: day_of_month 1  & current month_and_year + month - day
A: Mon, 31 Dec 2018
T: 0.051 ms
I: singular date

// The last day of every month, is the day before the first day of the following month
q: (day_of_month 1  & current month_and_year + (it * month) - 1 * day) of integers in (1,12)
A: Mon, 31 Dec 2018
A: Thu, 31 Jan 2019
A: Thu, 28 Feb 2019
A: Sun, 31 Mar 2019
A: Tue, 30 Apr 2019
A: Fri, 31 May 2019
A: Sun, 30 Jun 2019
A: Wed, 31 Jul 2019
A: Sat, 31 Aug 2019
A: Mon, 30 Sep 2019
A: Thu, 31 Oct 2019
A: Sat, 30 Nov 2019
T: 0.107 ms
I: plural date
3 Likes