- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 12:37 PM
Hi,
I need to allow user to select date after 7 days but it should calculate only business days not weekend. In our project as per client we follow Friday, Saturday as weekend and I need to exclude Friday, Saturday. When user select date then it should calculate for Sunday, Monday, Tuesday, Wednesday, Thursday as business day.
Can you please help me with that.
Regards,
Nivedita
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 12:55 PM
Hello @niveditakumari
Please try below code -
var startDate = new GlideDateTime("2024-03-22"); // Fixed start date
var businessDays = 7;
var daysAdded = 0;
while (daysAdded < businessDays) {
startDate.addDays(1); // Move to the next day
var dayOfWeek = startDate.getDayOfWeek(); // 1 = Sunday, 2 = Monday, ..., 7 = Saturday
if (dayOfWeek != 5 && dayOfWeek != 6) { // Exclude Friday (5) and Saturday (6)
daysAdded++;
}
}
// Print the final date in YYYY-MM-DD format
gs.info("Future Business Date: " + startDate.getValue());
I just tried it and its giving result
Kindly mark my answer helpful and accept solution if it helped you in anyway. This will help me be recognized for my efforts.
Regards,
Shivalika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2025 12:01 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2025 06:28 PM
Hello @niveditakumari
. It can be done via any server side script only. So, business rule. When user selects the date, you can cross validate it with this script and give error message.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2025 05:20 AM
Hi @Shivalika,
Can you please confirm which business rule and to which table do I need to write script.
Please confirm for above point.
Regards,
Nivedita