Going Stellar

Home/Smart values reference

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

ArgumentWhat it isRequired
date2The date to measure to, such as now or issue.duedateyes
unitmillis, seconds, minutes, hours, days, weeks, months, years or businessDays; add prettyPrint for words or abs for a positive numberyes

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:

15

Run 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:

-16

Run on Jira Cloud on .

Due in {{issue.duedate.diff(now).days.abs}} days

Removes the minus sign for a sentence, so the message reads Due in 16 days.

Result:

Due in 16 days

Run 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 seconds

Run 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:

12

Run 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:

-1

Run 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 .abs if 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).days was -16 but now.diff(issue.duedate).days was 15, because the time of day counts when now comes first (checked on Jira Cloud, November 2026).
  • The unit names are exact. .day and .days.absolute render 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").days renders 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.

Sources

  1. Jira smart values: date and time (Atlassian Support)
  2. Use smart values to manipulate and format dates (Atlassian Support)

Markdown version · All smart values