How to use date functions in Layer formulas to calculate time differences, next due dates, overdue flags, and asset age.

Mike Lee
Thursday, May 7, 2026
Layer formula fields support a set of built-in date functions. These functions let you add or subtract intervals from a date, compare dates, extract components such as the year or month, and format a date as a string. Layer treats dates and datetimes as a single date type. Time-of-day functions are available when the underlying field is configured as a datetime.
This article covers the date functions available in formula v2, common patterns built from them, and the behaviour to know about Layer's date model before you start.
Available date functions
Layer formulas group the date functions into three categories.
Add and subtract intervals
Each unit has its own add or subtract function. There is no generic DATE_ADD(date, n, unit) form.
Function | Description |
|---|---|
| Adds a number of days |
| Adds a number of weeks |
| Adds a number of months |
| Adds a number of years |
| Adds a number of hours |
| Adds a number of minutes |
| Adds a number of seconds |
| Subtracts a number of days |
| Subtracts a number of weeks |
| Subtracts a number of months |
| Subtracts a number of years |
| Subtracts a number of hours |
| Subtracts a number of minutes |
| Subtracts a number of seconds |
The second argument can be a number literal or a number field reference. Negative values are supported.
Compare dates
Function | Description |
|---|---|
| Returns TRUE when date1 is earlier than date2 |
| Returns TRUE when date1 is later than date2 |
| Returns TRUE when both dates are identical, including the time component |
| Returns TRUE when both dates fall on the same calendar day |
| Returns TRUE when both dates fall in the same ISO week |
| Returns TRUE when both dates fall in the same calendar month |
| Returns TRUE when both dates fall in the same calendar year |
| Returns TRUE when both dates fall in the same hour |
| Returns TRUE when both dates fall in the same minute |
Extract components and format
Function | Description |
|---|---|
| Returns the four-digit year |
| Returns the month as a number |
| Returns the ISO week number, |
| Returns the day of the week as a number |
| Returns the hour as a number |
| Returns TRUE when the date falls Monday through Friday |
| Returns TRUE when the date falls on Saturday or Sunday |
| Converts a date to a string using date-fns format tokens such as |
The current date and time is available through the NOW() utility function. Layer does not include a separate TODAY() helper. Pass NOW() to the comparison functions when you need to compare against the current moment.
Common patterns
Next maintenance due date
Add a fixed interval to the date a recurring task was last performed.
If the interval is itself stored as a number field, reference that field as the second argument.
Reminder date one week before an inspection
Overdue flag
Use a date comparison inside IF to label an element as overdue when its due date has passed.
Closed in the same week as reported
Format an inspection date for display
Year of installation as a number
Branch by weekday or weekend
Computing the difference between two dates
Layer formula v2 does not include a DATEDIFF style function that returns the number of days, weeks, or years between two dates as a single value. To express "is this after that," compare the dates with DATEISBEFORE or DATEISAFTER. To group elements by relative time periods, compare them with DATEISSAMEDAY, DATEISSAMEWEEK, DATEISSAMEMONTH, or DATEISSAMEYEAR.
If you need a numeric duration on the element, the most direct option is to store the duration as a number field rather than computing it inside a formula.
Things to know
MONTH and DAY are zero-indexed. MONTH(2026-01-15) returns 0, not 1. DAY returns the day of the week, not the day of the month, and counts Sunday as 0.
Month arithmetic at boundaries. DATEADDMONTHS(2026-01-31, 1) returns 2026-02-28 because February has fewer days. Test boundary cases when your formulas depend on month-level precision.
NOW() is a datetime in UTC. Comparisons that mix a datetime field and a date-only field can produce unexpected results around midnight. Match the field type, or pass both through DATEISSAMEDAY.
Field references in the visual editor. The visual formula editor inserts field references when you drag or select a field. The {Field Name} notation in the examples above is shorthand for communicating structure in writing.

