# Comparing dates in Jira Automation: syntax and examples

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

isAfter() and isBefore() answer true or false for two dates. compareTo() gives a number that is negative, positive or zero. Use them in advanced compare conditions, for example to test whether a due date falls inside the next 30 days.

## Syntax

```
{{date1.isAfter(date2)}}
{{date1.isBefore(date2)}}
{{date1.isEquals(date2)}}
{{date1.compareTo(date2)}}
```

## Arguments

- `date2` (required: yes): The date to compare with, such as now, issue.created or now.plusDays(30)

## Works on

- Fields: any two date or date-time values
- Returns: true or false, or a number for compareTo()

## Examples

```
{{issue.duedate.isAfter(now)}}
```

Tests whether the due date is still ahead.

Result:

```
true
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.duedate.isBefore(now.plusDays(30))}}
```

Tests whether the due date falls within the next 30 days; plusDays() builds the second date.

Result:

```
true
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.updated.isAfter(issue.created)}}
```

Tells whether the work item changed after it was created.

Result:

```
true
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.duedate.compareTo(issue.created)}}
```

Is positive when the second date is earlier than the first, for example the due date against the creation date.

Result:

```
1
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.created.compareTo(issue.duedate)}}
```

The reverse order gives a negative number.

Result:

```
-1
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.duedate.compareTo(issue.duedate)}}
```

Gives 0 for two equal date-only values.

Result:

```
0
```

Run on Jira Cloud on 29 Nov 2026.

## Where the documentation differs

- `{{issue.updated.isEquals(issue.created)}}`: run on Jira Cloud, 29 Nov 2026: the documentation says `false`, the actual result is ``.
- `{{now.compareTo(now)}}`: run on Jira Cloud, 29 Nov 2026: the documentation says `0`, the actual result is `16`.

## Pitfalls

- `isEquals()` rendered empty in every check, including a value compared with itself (`issue.duedate.isEquals(issue.duedate)`), so it cannot drive a rule today. Combine isAfter() and isBefore(), or compare with compareTo() (checked on Jira Cloud, November 2026).
- `compareTo()` returns 1 or -1, not the size of the gap. For two identical date-times it gave 16 instead of 0 (`issue.created.compareTo(issue.created)`), while two equal due dates gave 0. Do not test for equality of date-times with it (checked on Jira Cloud, November 2026).
- An argument that is not a date, such as `now.isAfter(issue.summary)`, or a missing argument renders empty rather than false.
- In a text field, `{{#if(...)}}a{{else}}b{{/}}` did not work as if/else: with a true condition it printed both a and b, with a false one it printed nothing (checked on Jira Cloud, November 2026). Branch with the compare condition instead.

## Related

- [{{now}}](https://goingstellar.ro/reference/smart-values/now/)
- [diff()](https://goingstellar.ro/reference/smart-values/date-diff/)
- [plusDays() / minusDays() and other units](https://goingstellar.ro/reference/smart-values/date-plus-minus/)
- [{{#if}} … {{/}}](https://goingstellar.ro/reference/smart-values/if/)
- [equals() and exists() in conditions](https://goingstellar.ro/reference/smart-values/conditional-equals-exists/)
- [gt(), gte(), eq(), lt(), lte()](https://goingstellar.ro/reference/smart-values/number-comparisons/)

## 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/)

