How can I add duration field value to a date/time field value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2016 12:52 AM
Hi Guys,
How can I add a duration field value to a date/time field?
Last working day= resigned date(date/time field)+ notice period days (duration field value). I am writing an on-change request and passing values to a script include to calculate last working day.
Note: Last working day should be autopopulated and it should be in the date format.
e.g if resigned date is 1/10/2016
notice period days =30 days
last working day should be 30/10/2016
Thanks
shraddha
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2016 03:37 AM
Hi Shradha,
Instead of using date/time field you can use duration type field to store a duration value.
Check this thread:Client Script Date/Time Functions
Thanks,
farukh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2016 03:54 AM
i am using the same what you told me but i am not getting logic to write the script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2016 03:56 AM
http://wiki.servicenow.com/?title=GlideDateTime#addDaysLocalTime.28int.29
Use GlideDateTime in a Business Rule
var gdt = new GlideDateTime(current.u_resigned_date);
gdt.addDaysLocalTime(parseInt(current.u_notice_period_days));
current.u_last_working_day = gdt.getLocalDate();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2016 04:17 AM
Hi shraddha,
This i have done
I have written business Rule
Please mark my answer correct.If it helps
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************