Forms, fields and formulas

How do I calculate the days or hours between two dates, with or without weekends and holidays?

Use dateDiff for the gap between dates (weekends excluded by default, false() to include them) and calendarDays to count both ends and skip account holidays.

How-to

Short answer: dateDiff(Date1, Date2, "Day") counts working days between two dates and skips weekends. Add false() to include weekends. To count both the start and end dates, or to skip your account's holidays, use calendarDays.

Why it happens

  • dateDiff starts counting the day after the first date. Monday to Tuesday is 1.
  • By default dateDiff skips weekends only. Holidays are skipped only if you pass a holiday list.
  • Empty or wrong results usually come from the wrong argument order, mixing Date and Date & time values, or a missing parenthesis.

How to fix it

Pick the formula for your case:

  • Working days: dateDiff(Start_Date, End_Date, "Day"). Put the earlier date first.
  • All days: dateDiff(Start_Date, End_Date, "Day", false())
  • Hours: dateDiff(Start_Time, End_Time, "Hour"), or add false() to include weekend hours.
  • Skip specific holidays: pass them as a list, for example dateDiff(Start_Date, End_Date, "Day", true(), ["2026-01-01", "2026-12-25"]).
  • Count both ends, skipping weekends and account holidays: calendarDays(Start_Date, End_Date, "D", "WD"). Use "AD" for every day.

When one value is a Date & time, such as _completed_at, convert it to a date first:

dateDiff(Date_Field, date(_completed_at.year(), _completed_at.month(), _completed_at.day()), "Day")

To show the day name, use Date_Field.toText("dddd"). weekDay() returns 1 for Sunday through 7 for Saturday.

To compare against fixed dates, use date() rather than text, for example today() >= date(2024, 11, 1).

See dateDiff function, calendarDays function and date expressions.

Tip

Set weekends and holidays in Account administration > Account settings > Weekends and holidays. Holidays don't recur, so add each year's list yourself. See weekends and holidays.

Related answers