Jira Automation smart value
diff() in Jira Automation: syntax and examples
{{date1.diff(date2).unit}} returns how much time lies from date1 to date2 in the unit you name. It is negative when date2 is earlier than date1. Use it for days until a due date, age of a work item, or the number of business days left.
Syntax
{{date1.diff(date2).unit}}
Arguments
| Argument | What it is | Required |
|---|---|---|
date2 | The date to measure to, such as now or issue.duedate | yes |
unit | millis, seconds, minutes, hours, days, weeks, months, years or businessDays; add prettyPrint for words or abs for a positive number | yes |
Works on
- Fields: any two date or date-time values
- Returns: a whole number, or text with prettyPrint
Examples
{{now.diff(issue.duedate).days}}Counts the full days left until the due date. The 7 hours and 35 minutes that remain on the 15th are dropped.
Result:
15Run on Jira Cloud on .
{{issue.duedate.diff(now).days}}The same two dates the other way round: the due date is the first value, so the answer is -16 calendar days.
Result:
-16Run on Jira Cloud on .
Due in {{issue.duedate.diff(now).days.abs}} daysRemoves the minus sign for a sentence, so the message reads Due in 16 days.
Result:
Due in 16 daysRun on Jira Cloud on .
{{now.diff(issue.duedate).prettyPrint}}Writes the gap in words for a reminder, without choosing a unit.
Result:
15 days 7 hours 35 minutes 3 secondsRun on Jira Cloud on .
{{now.diff(issue.duedate).businessDays}}Counts the weekdays between today and the due date, for an SLA that skips weekends.
Result:
12Run on Jira Cloud on .
{{issue.duedate.diff(issue.duedate.minusDays(40)).months}}Chains minusDays() to build a second date, and shows that months are whole months: -1.
Result:
-1Run on Jira Cloud on .
Pitfalls
- The sign follows the order: the result is date2 minus date1.
now.diff(issue.duedate)is positive for a due date in the future,issue.duedate.diff(now)is negative. Add.absif only the size matters. - A date-only field such as the due date is counted in calendar days when it comes first. With the due date on 15 December and today 29 November,
issue.duedate.diff(now).dayswas -16 butnow.diff(issue.duedate).dayswas 15, because the time of day counts when now comes first (checked on Jira Cloud, November 2026). - The unit names are exact.
.dayand.days.absoluterender empty. Units are whole numbers, so 16 days gives -2 weeks, not -2.3. - A text date is not accepted:
now.diff("2026-01-01").daysrenders empty. Without a unit, diff() prints the prettyPrint text.
Questions and answers
How do I get the age of a work item in hours?
{{now.diff(issue.created).hours}}. Because created is earlier than now, the value is negative; add .abs for a positive number.
Related
- {{now}}
- isAfter(), isBefore(), isEquals(), compareTo()
- toBusinessDay(), plusBusinessDays() and business-day helpers
- plusDays() / minusDays() and other units
- toDate (text to date)
- {{#=}} math expressions