
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2024 11:56 PM - edited 10-26-2024 11:58 PM
Hi All,
I am facing weird scenario. I am using script include and getting planned start and end as a input from client script.
Please refer below script for reference. Suppose, if I have selected input date as 2024-10-26 03:10:05 (planned start) to 2024-10-26 10:08:06 (planned end). I am using GlideDateTime to set the time of the date from the mid night (00:00:01) to end of the day (23:59:59). The intention is to cover all the time slots on that day which is present in the table data.
When I put the logs notes, I noticed that when I am fecting the dates in SI is showing as expected but when I am trying to set the timings to the given dates(as mentioned above), Planned Start date is getting preponed to 25th Oct.
What is the reason its only changing Planned start date , not Planned end date though I am using same conversion/functionality to set the timings ? (refer the snaps and script lines given as below)
In line# 6 and 7, I am receiving Dates from client script (refer snap 1)
In line# 9 and 10, setting timings to given dates.
When I checked logs its showing preponed date ( refer snap 2)
==========================================================================
// here are the few script lines given
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2024 02:27 AM
Hi @Virendra K ,
Can you check the below script:
var plannedStart = new GlideDateTime(this.getParameter("sysparm_startDt")); // Planned start date
var plannedStartDate = plannedStart.getDate();
var plannedEnd = new GlideDateTime(this.getParameter("sysparm_endDt")); // Planned end date
var plannedEndDate = plannedEnd.getDate();
gs.log('Vir: Start and End dt 1st= ' + plannedStart + " to " + plannedEnd);
var newPlannedStart = new GlideDateTime(plannedStartDate + " 12:00:00");
var newPlannedEnd = new GlideDateTime(plannedEndDate + " 23:59:00");
gs.log('Vir: Start and End dt 1st= ' + newPlannedStart + " to " + newPlannedEnd);
From Scripts - background, I have validated it.
var plannedStart = new GlideDateTime(); // Planned start date
var plannedEnd = new GlideDateTime();
plannedEnd.addDaysUTC(2);
//var plannedStart = new GlideDateTime(this.getParameter("sysparm_startDt")); // Planned start date
var plannedStartDate = plannedStart.getDate();
//var plannedEnd = new GlideDateTime(this.getParameter("sysparm_endDt")); // Planned end date
var plannedEndDate = plannedEnd.getDate();
gs.log('Vir: Start and End dt 1st= ' + plannedStart + " to " + plannedEnd);
var newPlannedStart = new GlideDateTime(plannedStartDate + " 12:00:00");
var newPlannedEnd = new GlideDateTime(plannedEndDate + " 23:59:00");
gs.info(newPlannedStart + ' ---- ' + newPlannedEnd);
Output:
*** Script: Vir: Start and End dt 1st= 2024-10-27 09:26:18 to 2024-10-29 09:26:18
*** Script: 2024-10-27 12:00:00 ---- 2024-10-29 23:59:00
If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2024 02:27 AM
Hi @Virendra K ,
Can you check the below script:
var plannedStart = new GlideDateTime(this.getParameter("sysparm_startDt")); // Planned start date
var plannedStartDate = plannedStart.getDate();
var plannedEnd = new GlideDateTime(this.getParameter("sysparm_endDt")); // Planned end date
var plannedEndDate = plannedEnd.getDate();
gs.log('Vir: Start and End dt 1st= ' + plannedStart + " to " + plannedEnd);
var newPlannedStart = new GlideDateTime(plannedStartDate + " 12:00:00");
var newPlannedEnd = new GlideDateTime(plannedEndDate + " 23:59:00");
gs.log('Vir: Start and End dt 1st= ' + newPlannedStart + " to " + newPlannedEnd);
From Scripts - background, I have validated it.
var plannedStart = new GlideDateTime(); // Planned start date
var plannedEnd = new GlideDateTime();
plannedEnd.addDaysUTC(2);
//var plannedStart = new GlideDateTime(this.getParameter("sysparm_startDt")); // Planned start date
var plannedStartDate = plannedStart.getDate();
//var plannedEnd = new GlideDateTime(this.getParameter("sysparm_endDt")); // Planned end date
var plannedEndDate = plannedEnd.getDate();
gs.log('Vir: Start and End dt 1st= ' + plannedStart + " to " + plannedEnd);
var newPlannedStart = new GlideDateTime(plannedStartDate + " 12:00:00");
var newPlannedEnd = new GlideDateTime(plannedEndDate + " 23:59:00");
gs.info(newPlannedStart + ' ---- ' + newPlannedEnd);
Output:
*** Script: Vir: Start and End dt 1st= 2024-10-27 09:26:18 to 2024-10-29 09:26:18
*** Script: 2024-10-27 12:00:00 ---- 2024-10-29 23:59:00
If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 03:58 AM
Thanks for the reply and help @Najmuddin Mohd .
I made the changes accordingly for dates/time.