We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 69c730d commit a2cc679Copy full SHA for a2cc679
Server-Side Components/Script Includes/Calculate Business days dynamically/script.js
@@ -0,0 +1,18 @@
1
+// Function to add any number of business days to a given date
2
+function add_business_days(date, num_days) {
3
+ var result_date = new GlideDateTime(date);
4
+ var added_days = 0;
5
+
6
+ while (added_days < num_days) {
7
+ result_date.addDaysUTC(1);
8
+ var day_of_week = result_date.getDayOfWeekUTC();
9
+ if (day_of_week != 6 && day_of_week != 7) { // Skip Saturday (6) and Sunday (7)
10
+ added_days++;
11
+ }
12
13
14
+ return result_date.getDate();
15
+}
16
17
+// Example usage:
18
+gs.print(add_business_days('2025-10-24 12:00:00', 5)); // Adds 5 business days
0 commit comments