Breadcrumbs

Months elapsed

📚

This template displays the months elapsed from the date selected in the date field of your choice until today.

If the field does not have a value, “None” will be displayed.

For the parameter Date field, pick the Date field that should be compared against the current day.

Configuration

To use the Months elapsed template, simply select it from the template grid. Filter by Misc to find it faster.

Parameters

To complete the configuration, select values for all parameters.

grafik-20250602-091901.png

Expert mode

If you switch to Expert mode you can see the formula field in the Expression Parser. You can now tweak the expression to create a custom formula field based on this template.

Expression

General expression:

%{{issue.cfnnnnn} != null ? ((year({system.currentDateTime}, RUN_AS_LOCAL) - year({issue.cfnnnnn}, RUN_AS_LOCAL))*12 + month({system.currentDateTime}, RUN_AS_LOCAL) - (month({issue.cfnnnnn}, RUN_AS_LOCAL))) : null} 

NNNNN is the ID of the custom field you chose for the “Date picker” parameter.

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 months that have passed from a specific date (chosen from a custom date field in a work item) up to today. If the date field is empty, it returns null.

2. Step-by-step breakdown

Let’s break it down:

  • {issue.cfnnnnn}: This refers to the value of a custom date field in the work item. Replace nnnnn with the actual field ID.

  • {system.currentDateTime}: This represents the current date and time.

  • != null ? ... : null: This checks if the custom date field has a value. If it does, the calculation is performed; if not, the result is null (which displays as “None”).

  • year(...): Extracts the year from a date.

  • month(...): Extracts the month from a date.

  • The calculation:

    • (year(today) - year(selected date)) * 12: Calculates the difference in years and converts it to months.

    • + month(today) - month(selected date): Adds the difference in months.

    • The total gives the number of months elapsed between the selected date and today.

3. Examples

Suppose the custom date field contains “2023-02-10” and today is “2026-02-10”:

  • Year difference: 2026 - 2023 = 3 years → 3 * 12 = 36 months

  • Month difference: 2 (February) - 2 (February) = 0 months

  • Total: 36 + 0 = 36 months elapsed

If the custom date field is empty, the result will be null.

4. Real-life use cases

  • Tracking how many months have passed since a contract start date in a work item.

  • Calculating the time since a product was released or a service was activated.

  • Monitoring the duration since a customer joined, for reporting or follow-up purposes.