Return the number of days remaining until the due date.
Configuration
Create a smart number field and use the General parsing mode.
Expression
%{{issue.dueDate} != null ? floor(max({issue.dueDate} - datePart(
{system.currentDateTime}, RUN_AS_LOCAL), 0)/ DAY) : null
Display as
Number
Formatting style
Default (unformatted)
Used parser functions
The links lead to the JWTC documentation because the parser functions are shared functionalities.
Details
1. What does the expression do?
This expression calculates the number of days remaining until the due date of a work item. If there is no due date set, it returns null (nothing).
2. Step-by-step breakdown
Let’s break it down:
-
{issue.dueDate} != null ? ... : null-
This checks if the work item has a due date. If not, the result is null (nothing is returned).
-
-
{issue.dueDate} - datePart({system.currentDateTime}, RUN_AS_LOCAL)-
This subtracts the current date and time (in your local timezone) from the due date of the work item. The result is the time difference in milliseconds.
-
-
max(..., 0)-
This ensures that if the due date has already passed, the result will not be negative. If the difference is negative, it uses 0 instead.
-
-
... / DAY-
This converts the time difference from milliseconds to days.
-
-
floor(...)-
This rounds the number of days down to the nearest whole number.
-
3. Examples
-
If today is November 13 and the due date is November 15, the expression returns 2.
-
If the due date is today, the expression returns 0.
-
If the due date has already passed, the expression returns 0 (not a negative number).
-
If there is no due date, the expression returns null (nothing).
4. Real-life use cases
-
Displaying a countdown of days left until a task or work item is due.
-
Highlighting work items that are approaching their due date.
-
Creating dashboards or reports that show how much time is left for each work item.
-
Triggering reminders or alerts when the number of days remaining is low.