Trying to create a budget that will adjust for weekends and holidays

I have been using a nested formula that uses weekday for weekends, workday for the holidays, and edate to return a date the following month that gets adjusted by the first two functions. The problem is, my formula adjusts for weekends but not holidays. I have tried formatting differently, checking the references, and always to no avail. I will upload a template of the master spreadsheet for analysis.

My formula for returning a date the following month that will not yield a weekend or Federal Holiday (thus, when the banks are closed) is as follows:

=IF(WEEKDAY(WORKDAY(EDATE($'Start Dates'.J9,1),0,$C$3:$C$26))=7,WORKDAY(EDATE($'Start Dates'.J9,1),0,$C$3:$C$26)-1,IF(WEEKDAY(WORKDAY(EDATE($'Start Dates'.J9,1),0,$C$3:$C$26))=1,WORKDAY(EDATE($'Start Dates'.J9,1),0,$C$3:$C$26)-2,WORKDAY(EDATE($'Start Dates'.J9,1),0,$C$3:$C$26)))

The way Im reading this is, in the first line of text, if the weekday=7, in other words, Saturday, we subtract 1 to kick it back to a friday. The workday function gives me the start date and holiday parameters, and the edate function makes the result exactly one month in the future. The second line of text kicks the resulting date back two days in the case that the future date falls on Weekday=1, a Sunday, and failing that, it employs the condition to advance it based on a day the following month. So in other words, any return date that falls on a weekend gets kicked back to the previous Friday, where the Workday function is *supposed * to take the holidays into account and advance it accordingly. It doesn’t.

The formula I have copied returns a date 4 September of this year from the starting date of 4 Aug from reference Start Dates cell J9. 4 Sep is Labor Day even though I double-checked to make sure that is in the list of Holidays, where I have highlit 4 Sep to make it easier to note the discrepancy.

The formula works as far as not returning a date on a weekend, but is ignoring the holidays I have defined, on C3:C26 on the calculations page, where the work is being performed. The Calculations page gets the start date for the bill/subscription for the previous month on the Start Dates page.

As you can see from the spread, I have highlighted the occurrences where the formula fails to compensate for the Holidays I have assigned for this year and 2024. My question is, why does the Workday function fail to take those dates into account, and how do I compensate?

Thank you.
Any assistance is greatly appreciated
Template.ods (58.3 KB)

I’m confused, there’s a lot of information in the spreadsheet, and I can’t check the formula, because I don’t understand what you want to answer.

Do the following, take a specific cell and describe what you want in response.

Note, work with .ods files in LibreOffice, it will be more convenient not to have problems in the future.

Is Easter a holiday? I don’t see it there. Easter Sunday =FLOOR.XCL(DAY(MINUTE(A2/38)/2+56)&"/5/"&A2,7)-34 where A2 contains the year, e.g. 2024. Good Friday -2 & Easter Monday +1.

1 Like

yes we can do the hard way…so that we do not violate the sacred compatibility with Excel … or we use the calc builtin-function EASTERSUNDAY( … )

off topic: there are really funny ways to »calculate« eastersunday for example: with sed

1 Like

You are absolutely right. You caught me out, I just lazily looked up a spreadsheet I did in 2004 in Excel :slight_smile:

Certainly, Mr. Schiavinatto. I will describe my problem more succinctly and change the format of the spread immediately. Thank you for your timely response!

Al, thank you also for your timely response. The Federal Holidays unfortunately do not include Easter Sunday or a weekly Observance Day (God knows they should, we still celebrate Christmas), as you can see here

New Years - Sun, 1 Jan, 23
New Years Observed - Mon, 2 Jan, 23
Martin Luther King - Mon, 16 Jan, 23
President’s Day - Mon, 20 Feb, 23
Memorial Day - Mon, 29 May, 23
Juneteenth - Mon, 19 Jun, 23
Independence Day - Tue, 4 Jul, 23
Labor Day - Mon, 4 Sep, 23
Columbus Day - Mon, 9 Oct, 23
Veterans Day - Fri, 10 Nov, 23
Veterans Day Observed - Sat, 11 Nov, 23
Thanksgiving - Thu, 23 Nov, 23
Christmas Day - Mon, 25 Dec, 23

I appreciate the suggestion, however :slight_smile:

Noted. Thank you for your response, Karolus

See formula in D5.

Corrected version…
LinuxMint_ask_en_94931_Template2.ods (44.8 KB).

1 Like

We did it! Your formula was close enough and inspiring enough that I was able to tweak it and adjust for all the cells. Im uploading my newest template. This was the magic formula:

=WORKDAY($'Start Dates'.J9,NETWORKDAYS($'Start Dates'.J9,EDATE($'Start Dates'.J9,1))-1,$C$3:$C$26)

I love how simple, yet effective, your formula was! Thanks again sir.

1 Like