- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 07:08 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 08:48 PM
Hello @shiz ,
Try below code:
function executeRule(current, previous /*null when async*/) {
// Extract the current date
var actualTimeDetailsRecord = new Date(current.u_week_starts_on);
// Calculate dates for each day of the week
var mondayDate = new Date(actualTimeDetailsRecord); // Start date (Monday)
var tuesdayDate = new Date(actualTimeDetailsRecord);
tuesdayDate.setDate(tuesdayDate.getDate() + 1); // Add 1 day for Tuesday
// To calculate a date 7 days after the start date
var sevenDaysLater = new Date(actualTimeDetailsRecord);
sevenDaysLater.setDate(sevenDaysLater.getDate() + 7); // Add 7 days
// Output the dates
gs.info('Monday Date: ' , mondayDate);
gs.info('Tuesday Date: ' , tuesdayDate);
gs.info('7 Days Later: ' , sevenDaysLater);
}
Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.
Thanks and Regards,
Ashish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 08:51 PM
In this example, replace yourDateField
with the actual field name where you want to set the next day's date.
This script gets the current date and time, adds one day to it, and then sets the result to the specified field.
(function executeRule(current, previous) {
var currentDate = new GlideDateTime(gs.nowDateTime());
currentDate.addDays(1);
current.yourDateField = currentDate.getDisplayValue();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 07:44 PM - edited 11-20-2024 09:38 PM
Hello @shiz
Try
var TomorrowDate = new GlideDate();
//Add number depending on your requirement
TomorrowDate.addDaysLocalTime(1);
gs.addInfoMessage("Date is: " + TomorrowDate)
Please mark the answer as helpful and correct if helped
Kind Regards,
Ravi Chandra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 08:48 PM
Hello @shiz ,
Try below code:
function executeRule(current, previous /*null when async*/) {
// Extract the current date
var actualTimeDetailsRecord = new Date(current.u_week_starts_on);
// Calculate dates for each day of the week
var mondayDate = new Date(actualTimeDetailsRecord); // Start date (Monday)
var tuesdayDate = new Date(actualTimeDetailsRecord);
tuesdayDate.setDate(tuesdayDate.getDate() + 1); // Add 1 day for Tuesday
// To calculate a date 7 days after the start date
var sevenDaysLater = new Date(actualTimeDetailsRecord);
sevenDaysLater.setDate(sevenDaysLater.getDate() + 7); // Add 7 days
// Output the dates
gs.info('Monday Date: ' , mondayDate);
gs.info('Tuesday Date: ' , tuesdayDate);
gs.info('7 Days Later: ' , sevenDaysLater);
}
Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.
Thanks and Regards,
Ashish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 08:51 PM
In this example, replace yourDateField
with the actual field name where you want to set the next day's date.
This script gets the current date and time, adds one day to it, and then sets the result to the specified field.
(function executeRule(current, previous) {
var currentDate = new GlideDateTime(gs.nowDateTime());
currentDate.addDays(1);
current.yourDateField = currentDate.getDisplayValue();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 09:05 PM
Hello @shiz
Please refer the below script:
(function executeRule(current, previous) {
var gdtCurrentDate = new GlideDateTime();
gdtCurrentDate.addDays(7); //Add 7 day from today local date
gs.info("Date 7 days from today" + gdtCurrentDate);
})(current, previous);
Hope this helps!
"If you found my answer helpful, please like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar