How can I add duration field value to a date/time field value?

shradz
Kilo Explorer

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

find_real_file.png

Thanks

shraddha

10 REPLIES 10

fkhan
Kilo Guru

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


i am using the same what you told me but i am not getting logic to write the script


Geoffrey2
ServiceNow Employee
ServiceNow Employee

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();


PrashantLearnIT
Giga Sage

Hi shraddha,


                                      This i have done


                                      find_real_file.png


                                    I have written business Rule



                                    find_real_file.png



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
********************************************************************************************************