# diff() in Jira Automation: syntax and examples

URL: https://goingstellar.ro/reference/smart-values/date-diff/

{{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

- `date2` (required: yes): The date to measure to, such as now or issue.duedate
- `unit` (required: yes): millis, seconds, minutes, hours, days, weeks, months, years or businessDays; add prettyPrint for words or abs for a positive number

## 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 29 Nov 2026.

```
{{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 29 Nov 2026.

```
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 29 Nov 2026.

```
{{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 29 Nov 2026.

```
{{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 29 Nov 2026.

```
{{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 29 Nov 2026.

## 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.

## Related

- [{{now}}](https://goingstellar.ro/reference/smart-values/now/)
- [isAfter(), isBefore(), isEquals(), compareTo()](https://goingstellar.ro/reference/smart-values/date-compare/)
- [toBusinessDay(), plusBusinessDays() and business-day helpers](https://goingstellar.ro/reference/smart-values/business-days/)
- [plusDays() / minusDays() and other units](https://goingstellar.ro/reference/smart-values/date-plus-minus/)
- [toDate (text to date)](https://goingstellar.ro/reference/smart-values/todate/)
- [{{#=}} math expressions](https://goingstellar.ro/reference/smart-values/math-expressions/)

## Sources

- [Jira smart values: date and time (Atlassian Support)](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/)
- [Use smart values to manipulate and format dates (Atlassian Support)](https://support.atlassian.com/cloud-automation/docs/examples-of-using-smart-values-with-dates/)

