Substract days using GlideSchedule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 11:43 AM
Hi All,
We have requirement to substract 3 working days from particular date (Maturity date) and add the validations based on newly calculated date.
Can anyone please assist how to use GlideSchedule to substract from Maturity date or is there any other method to achieve this.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 11:57 AM
HI @Poonam Mahajan ,
I trust you are doing great.
Here's an example of how you can achieve this using GlideSchedule:
// Assuming the Maturity date is stored in a variable called 'maturityDate'
var maturityDate = new GlideDateTime('2023-05-31 00:00:00'); // Replace with your actual Maturity date
// Create a GlideSchedule object to represent the working schedule
var schedule = new GlideSchedule();
// Subtract 3 working days from the Maturity date
var newDate = schedule.durationAfter(maturityDate, -3); // Subtract 3 working days
// Perform your validations based on the newly calculated date
if (newDate) {
// Validation logic goes here
gs.info('New calculated date: ' + newDate);
} else {
gs.error('Failed to calculate the new date.');
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2023 03:02 AM
Hi @Amit Gujarathi :
Thanks you for your response.
I tried above code snippet, but its giving me this error
Script: Failed to calculate the new date.: no thrown error
Could you please assist.
Thanks