LookupLab
Home › Use Cases › Excel Formulas for HR & Payroll

Excel Formulas for HR & Payroll

Payroll runs on calendar math: how many working days in the period, when is the cutoff, how many complete years has someone served. These four functions cover it — including DATEDIF, the one Excel hides from the function wizard.

The functions you will actually use

FunctionWhat it does in this workflow
NETWORKDAYSWorking days between two dates, excluding weekends and a holiday list.
WORKDAYThe date N working days after a start date — payroll cutoffs and SLA deadlines.
DATEDIFComplete years/months/days between dates: tenure, age, service anniversaries.
DAYSSimple calendar-day difference (no weekend logic).
EOMONTHLast day of the month N months away — period-end reporting.
TODAYRolling “as of” date for tenure and aging reports.
ROUNDRound hourly rates and prorated amounts to cents.
SUMIFTotal hours or cost per employee / department / pay code.

Worked examples (engine-computed)

Working days in November 2026 (Mon–Fri)
=NETWORKDAYS(DATE(2026,11,1), DATE(2026,11,30))
Result: 21 — computed with the same HyperFormula 3.5 engine that powers our labs, not hand-calculated.
Complete years of service: hired 2020-03-15, as of 2026-11-23
=DATEDIF(DATE(2020,3,15), DATE(2026,11,23), "Y")
Result: 6 — computed with the same HyperFormula 3.5 engine that powers our labs, not hand-calculated.
Payroll cutoff: 10 working days after 2026-11-23
=TEXT(WORKDAY(DATE(2026,11,23), 10), "yyyy-mm-dd")
Result: 2026-12-07 — computed with the same HyperFormula 3.5 engine that powers our labs, not hand-calculated.
The mistake to avoid. Two DATEDIF gotchas. (1) The unit argument is a quoted string — "Y" counts completed years, so someone hired 2020-03-15 is still 6 years served on 2026-11-23, not 7. (2) Some engines are case-sensitive about the unit; uppercase "Y"/"M"/"D" is the safe form. And NETWORKDAYS assumes a Saturday–Sunday weekend; for other schedules use its .INTL variant in Excel.

Is DATEDIF safe to use if Excel doesn't list it?

Yes — DATEDIF is a documented compatibility function kept for Lotus 1-2-3 migration; it works in all modern Excel versions and Google Sheets. It just does not appear in the insert-function dialog. Our DATEDIF lab covers every unit including YM and MD.

How do I exclude company holidays from NETWORKDAYS?

Pass a range of holiday dates as the third argument: =NETWORKDAYS(start, end, Holidays!A2:A20). Keep the holiday list on its own sheet so each year is a one-range update.

Building a payroll calendar?

Start with the NETWORKDAYS and WORKDAY labs — both let you paste your own dates and see the result instantly, free, no signup.

Open NETWORKDAYS labOpen WORKDAY lab

Other use cases