How to calculate days correctly between two days excluding 2nd and 4th Saturday and all sunday and excluding holidays.
Start date is counted as zero day
End date should be yesterday date
Example:-
start date is (27-Nov-2025)+1
End date is today()-1
In between Sunday on 30-Nov-2025
This givs me result as 4, but actual days is 5
Edit: Changed subject, was How to calculate days correctly between two days excluding 2nd and 4th Saturday and all sunday and excluding holidays Make your post understandable by others
-- MrProgrammer, forum moderator
Last edited by MrProgrammer on Thu Dec 04, 2025 5:09 pm, edited 1 time in total.
Reason:Edited topic's subject to provide a summary, not all the rules
Why did you post this question in the "Macros" branch?
How should somebody trying to help you know YOUR holidays?
Depending on traditions there may be "moving holidays".
The federal rebublic I live in has 16 member states, and each one can define holidays independently. In the member state I live in some holidays depend in addition on regional specifics.
There is a standard function NETWORKDAYS() to help a bit with such stuff, and it was enhanced in LibreOffice. Nevertheless you can't avoid some handiwork if you want to apply badly considered rules. I feel sure that a macro will not be the appropriate choice.
You may list all the dates in the possible range in a column, and decide in a second column for each date if it is a workday in your sense or not. Concerning the weekends and the funny distinction for saturdays this can be done with the help of standard formulas. Concerning the holidays you will need a next column for the "exceptions".
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Lupp wrote: ↑Sat Dec 06, 2025 6:02 pm
@MrProgrammer: The thread should be moved to the Calc forum.
This means that the OP is unlikely to receive assistance with a macro, which was perhaps their goal. Another moderator had already taken that action before I saw your note. You can ask for help from the moderation team without naming an individual by reporting the post (❗️icon) and putting your reason in the report. Lovepreet323 can request that the topic be moved back to the Macros and UNO API forum if they really want a macro, though perhaps Lupp's method may provide the solution they seek.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).