Code snippet to calculate the number of working days between two dates

Abstract

This code snippet calculates the number of working days between two given dates.

Logic

Use the workdaysBetween() function of JMCF to calculate the work days between the two specified dates

Snippet

workdaysBetween( <fromDate> , <toDate> )

Placeholders

Placeholder

Description

Example

<fromDate>From dateissue.created
<toDate>To dateissue.duedate

Examples

The output of this code is the number of working days between the specified dates, which you could use in a Groovy expression to:

  • Calculate and display the number of working days between the issue creation date and Due date

    if (issue.duedate){
     "This ticket should be resolved in" + workdaysBetween( issue.created  , issue.duedate ) + "days" 
    }
  • Group issues based on the number of working days between the issue creation and resolution

    workdaysBetween( issue.created  , issue.resoultiondate)

References