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
| Function | What it does in this workflow |
|---|---|
| NETWORKDAYS | Working days between two dates, excluding weekends and a holiday list. |
| WORKDAY | The date N working days after a start date — payroll cutoffs and SLA deadlines. |
| DATEDIF | Complete years/months/days between dates: tenure, age, service anniversaries. |
| DAYS | Simple calendar-day difference (no weekend logic). |
| EOMONTH | Last day of the month N months away — period-end reporting. |
| TODAY | Rolling “as of” date for tenure and aging reports. |
| ROUND | Round hourly rates and prorated amounts to cents. |
| SUMIF | Total hours or cost per employee / department / pay code. |
Worked examples (engine-computed)
=NETWORKDAYS(DATE(2026,11,1), DATE(2026,11,30))
=DATEDIF(DATE(2020,3,15), DATE(2026,11,23), "Y")
=TEXT(WORKDAY(DATE(2026,11,23), 10), "yyyy-mm-dd")
"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