Skip to content

DAYS_BETWEEN

Description

DAYS_BETWEEN takes a start date and an end date and returns the number of days between them, counting both the start day and the end day. DAYS_BETWEEN('2024-05-01', '2024-05-05') returns 5, and a start and an end on the same day return 1.

DAYS answers the other question, the plain gap between two dates, so the same two dates give 4 there. Use DAYS_BETWEEN to count the days something covered, and DAYS to measure the distance between two points in time.

An end date before the start date returns 0. For a service level agreement that reads as an answer given before the request arrived, so no time was used.

If you need the result in hours rather than days, use HOURS_BETWEEN.

The optional arguments that narrow what counts, and how values without a time are treated, are described under counting elapsed time.

Example

p is Person
DAYS_BETWEEN(
    start_date: p.request_received,
    end_date: p.request_answered,
    exclude_weekends: true
)

This returns the number of working days the request was open.

Arguments

The two dates can be passed positionally, DAYS_BETWEEN(p.request_received, p.request_answered), or by name. The other arguments narrow what counts as elapsed time. Give them by name, since their positional order is easy to get wrong. Naming any one of them means the two dates have to be named as well, otherwise DAYS_BETWEEN reports that start_date is missing while the dates sit unused in the positional arguments.

Argument Default Description
start_date required The first day that counts.
end_date required The last day that counts.
exclude_weekends false When true, Saturdays and Sundays do not count.
exclude_days none A list of dates that do not count, for public holidays.
exclude_before_time 00:00:00 Time each day starts counting, so 09:00:00 ignores the earlier hours.
exclude_after_time midnight Time each day stops counting.
day_length 24 Hours that make up one day, so 8 counts a working day as a full day.

Info

New in Atfinity 17. A named argument that is not in the table above is rejected, where it was previously ignored.