Conversation
…LK-563323] formulajs NETWORKDAYS has two bugs: - When start > end, the day-counting loop never runs, returning wrong results instead of a negative working-day count - Date objects with time-of-day produce fractional/off-by-one results due to Math.round on the ms difference Fix by stripping time from Date inputs and computing the forward result then negating when the initial call returns <= 0.
Flexicon
reviewed
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two bugs in the
NETWORKDAYSformula (viaformulajsProxy) that caused incorrect results for ClickUp formula custom fields:formulajsday-counting loop never runs whendays <= 0, returning 0 or wrong values instead of a negative working-day count. Excel/Sheets returns the negation of the forward count.formulajsusesMath.roundon the ms difference between dates, so time components cause fractional results (e.g.2.08instead of3) and off-by-one errors. Excel/Sheets ignores time-of-day entirely.Fix
Dateinputs before passing toformulajs(strings and serial numbers are unaffected —formulajs.parseDatehandles those correctly)<= 0, compute the reverse and negate to match Excel behaviorExamples
NETWORKDAYS("2013-12-05", "2013-12-04")0-2-2NETWORKDAYS("2013-12-05", "2013-11-04")-23-24-24NETWORKDAYS(Aug7 23:00, Aug9 01:00)2.0833Test plan
callVariableto injectDateobjects with time-of-dayPRs in the Stack
(The stack is managed by git-grok.)