Next Month's Date

Hey,

Anyone knows a relevance statement to determine next month’s third Tuesday date?

@brolly33 does!

https://www.ibm.com/developerworks/community/blogs/e9d21113-aa93-467e-ac77-a0d20a21eaec/entry/Simple_Answers_Maintenance_Window_related

1 Like

Thank you Jason! I love these types of relevance problems.
That blog entry does not totally answer the question but is a great starting point.

q: first tuesday of (current month_and_year + month)
A: Tue, 01 Jan 2019

q: (first tuesday of (current month_and_year + month)) + (14*day)
A: Tue, 15 Jan 2019

(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

Jason, I love this alternate approach. Yours is tighter and easier to read/understand and accommodates the months with variable lengths just as well as mine. :tada:
I am going to update the blog post with your improvement.

2 Likes

Very nice, so patch Tuesday’s for 2019 it would be something like

Q: (first tuesday of it + 7 * day) of ((current month_and_year + (it * month)) of integers in (1,12))
A: Tue, 08 Jan 2019
A: Tue, 12 Feb 2019
A: Tue, 12 Mar 2019
A: Tue, 09 Apr 2019
A: Tue, 14 May 2019
A: Tue, 11 Jun 2019
A: Tue, 09 Jul 2019
A: Tue, 13 Aug 2019
A: Tue, 10 Sep 2019
A: Tue, 08 Oct 2019
A: Tue, 12 Nov 2019
A: Tue, 10 Dec 2019
T: 0.126 ms
I: plural date
4 Likes