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.
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
I've given a similar script using ScriptRunner's Behaviour in this Community Question.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.