Calculate the End date based on the start date

Sirri
Tera Guru

Hi All,

 

Please help the Regarding  & Any source code available please share.

 

1)Start Date - date
2)Temporary Access Duration Required -Drop Down -

5 Minutes
15 Minutes
30 Minutes
1 Hour
5 Hours
12 Hours
1 Day
5 Days
10 Days


3)End Date -Date

 Note is for the end Date.
Note : Prepopuated Date Based on duration selected - Use 'start date' to calculate the 'end date'. uneditable/greyed out.
If minutes will select then end date should be as start date

5 REPLIES 5

Samaksh Wani
Giga Sage
Giga Sage

Hello @Sirri 

 

var gdt = new GlideDateTime(current.start_date);
if(current.dropdown_field=='1 Day'){
gdt.addDaysLocalTime(1);
}
if(current.dropdown_field == '30 Minutes')
{
var time= 60*30;
gdt.addSeconds(time);
}

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

Hi Samaksh/Dipen

 

I Have written the code please find the attached files.

 

 

 

Hello @Sirri 

 

It looks good, try and execute the code.

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

Dipen Wadhwana
Giga Guru

Hi @Sirri ,

 

Please checkout this link if it helps you.

https://www.servicenow.com/community/developer-forum/client-script-date-time-functions/m-p/1457091/h... 

 

Please mark my answer helpful and accept as solution if it helped you ✔️.