How to use operators in date variables?

Background

The date variables in ARN templates like [releaseDate], [sprintStartdate], [sprintEnddate], etc are replaced by their actual values (date) as fetched from Jira. However, there are ample use cases where users want to manipulate this date on the go and then use the calculated value in the ARN template.

For example, what if I want to include the number of days remaining for release or a date that is 15 days prior to the version release date which is basically our QA release date? In such a scenario system allows me to use some operators with the date type variables and display the calculated date in release notes.

Here is an example of how the value of [releaseDate] variable can be used with different operators.

 

 

Syntax

The syntax used to indicate the use of an operator in the date variable would be as follows

Date variable without any operator

Date variable with operator

[dateVariable]

[dateVariable|operatorName]

This will be replaced by actual date returned from Jira.

This will be replaced by the returned value after the calculations done based on the selected operator.

Operators

Below table explains the type of operators we support with some simple examples that will help you to understand how you can use these operators along with the date type variables.

Operator

Syntax

Calculations

Remaining days

[dateVariable|remainingDays]

  • This operator will calculate the difference between the date value in the selected variable and current date.

  • While calculating number of days, system excludes the current date.

  • Depending on the variable date is future or past date, system will return positive/negative number as number of remaining days.

  • Example 1

    • Selected date variable is [releaseDate]

    • Release date = 4th April 2045

    • Current date = 1st January 2045

    • Syntax - [releaseDate|remainingDays]

    • Output = 93


  • Example 2

    • Selected date variable is [releaseDate]

    • Release date - 15th February 2022

    • Current date - 25th February 2022

    • Syntax -[releaseDate|remainingDays]

    • Output -10

Elapsed days

[dateVariable|elapsedDays]

  • This operator lets you display the difference between the current date and the date returned by the selected date variable.

  • While calculating number of days, system excludes the date returned by the date variable. For example, if the selected date variable is [sprintStartdate], system will not count that day while calculating the number of Elapsed days.

  • Depending on the future/past date returned by from the selected date variable, system will return a negative or positive value respectively as the number of Elapsed days.

  • Example 1

    • Selected date variable is [sprintStartdate]

    • Sprint start date = 4th April 2023 (Let us assume it is a future date)

    • Current date = 1st January 2023

    • Syntax - [sprintStartdate|elapsedDays]

    • Output - -93


  • Example 2

    • Selected date variable = [sprintStartdate]

    • Sprint start date - 15th February 2022 (Let us assume it is a past date)

    • Current date - 25th February 2022

    • Syntax -[releaseDate|remainingDays]

    • Output - 10

Add/Subtract days

[dateVariable|+Number of days]

[dateVariable|-Number of days]

  • This operator will adds/subtract certain number of days from the to/from the date returned by the date selected date type variable and returns a new calculated date.

  • Example

    • Selected date variable = [releaseDate]

    • Release date - 4th April 2023

    • Syntax -

      • [releaseDate|+7d]

      • [releaseDate|-7d]

    • Output -

      • [4th April 2023|+7d] = 11th April 2023

      • [4th April 2023|-7d] = 27th March 2023

Add/Subtract months

[dateVariable|+Number of months]

[dateVariable|-Number of months]

  • Adds/subtracts certain number of months from the to/from the date returned by the date variable and calculates a new date.

  • For example

    • Selected date variable = [releaseDate]

    • Release date - 15th December 2022

    • Syntax -

      • [releaseDate|+6m

      • [releaseDate|-6m]

    • Output -

      • [15th December 2022|+6m] = 15th June 2023

      • [15th December 2022|-6m] = 15th June 2022

Add/Subtract years

[dateVariable|+Number of years]

[dateVariable|-Number of years]

  • Adds/subtracts certain number of months from the to/from the date returned by the date variable and calculates a new date.

  • For example

    • Selected date variable = [releaseDate]

    • Release date - 15th December 2022

    • Syntax -

      • [releaseDate|+3y

      • [releaseDate|-3y]

    • Output -

      • [15th December 2022|+3y] = 15th December 2025

      • [15th December 2022|-3y] = 15th December 2019

Extract date

[dateVariable|dd]

  • This operator extracts a two digit number (date) from the returned date from the selected date variable

  • System will returns two digit number i.e. date

  • For example

    • Selected date variable = [releaseDate]

    • Release date - 9th December 2022

    • Syntax - [releaseDate|dd] = 09

    • Output - 09

Extract month

[dateVariable|mm]

[dateVariable|mmm]

[dateVariable|mmmm]

  • This operator extracts a number/month name from the date that is returned by selected variable.

  • You can use different syntax depending on what output you wish to display, like two digit month number, month abbreviation or month full name.

  • For example

    • Selected date variable = [sprintStartdate]

    • Sprint start date - 15th August 2023

    • Syntax -

      • [sprintStartdate|mm

      • [sprintStartdate|mmm]

      • [sprintStartdate|mmmm]

    • Output -

      • 08

      • Aug

      • August

Extract year

[dateVariable|yy]

[dateVariable|yyyy]

  • This operator lets you extract the number year based on the date returned from the selected variable.

  • This returns a two digit year or full numeric year depending on the syntax you have used.

  • For example

    • Selected variable = [releaseDate]

    • Syntax -

      • [releaseDate|yy]

      • [releaseDate|yy]

    • Release date - 15th December 2023

    • Output -

      • 23

      • 2023

Applicable variables

Above operators will support only ARN date variables listed below -

  • startDate

  • releaseDate

  • sprintStartdate

  • sprintEnddate

  • sprintCompleteddate

  • currentDate

  • currentDatetime

  • timeStamp

Use cases

Below are some use cases that might help you to get an idea on how to use these operators.

  • To convey remaining days between current date and release date

  • To calculate and display elapsed days from the planned release that has already passed

  • Subtract number of days from the planned release date/sprint end date to notify the deadline to complete certain action/step in the process. Eg. QA release should happen before 15 days of the Product release then, subtract 15 days from release date and display QA release date.