How to check holidays fall in between two dates

Omprakash Thamsetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 24, 2025

Hi,

 

I have start Date and End date so how I can check holidays fall in between these two dates?

How many holidays fall ?

 

I have script runner plugin. How can I write script to find this? 

 

Any help much appreciated. 

2 answers

1 vote
Kawan Diogo
Contributor
January 24, 2025

Hi @Omprakash Thamsetty 

 

You can use scriptrunner to generate a script field to hold the value or use as a script check in 

Script Console, however you gonna need mantain an array with the holidays of the year, i know it's possible connect with some services to get the holidays of the year, but some of them are paid service, so you can also explore the connection with public API's to get the information and keep them in the array.

 

Here is the manual version of the script i mencioned:

 

import java.time.LocalDate
import java.time.format.DateTimeFormatter

// Input dates (you can replace these with your issue's field values or parameters)
def startDate = LocalDate.parse("2025-01-01", DateTimeFormatter.ISO_DATE)
def endDate = LocalDate.parse("2025-01-10", DateTimeFormatter.ISO_DATE)

// Define the list of holidays (in YYYY-MM-DD format)
def holidays = [
LocalDate.parse("2025-01-06"),
LocalDate.parse("2025-01-09")
]

// Filter holidays that fall within the range
def holidaysInRange = holidays.findAll { it.isAfter(startDate.minusDays(1)) && it.isBefore(endDate.plusDays(1)) }

// Output the result
def holidayCount = holidaysInRange.size()
log.info("Number of holidays between ${startDate} and ${endDate}: ${holidayCount}")

// Return the final value
return holidayCount

 

Let me know it this helps you.

 

Best Regards

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 24, 2025

Hi @Omprakash Thamsetty

I've given a similar script using ScriptRunner's Behaviour in this Community Question.

Thank you and Kind regards,
Ram

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.1
TAGS
AUG Leaders

Atlassian Community Events