Subtract No of Days from Date field to set New Date in a field (Scoped App)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 04:04 AM - edited 02-21-2024 04:15 AM
I need to Subtract No of Days(integer field) from a Date field to set New Date in a field for a Scoped App using BR please help me with the logic for scoped application to get the new Date.
Example
field a -> 2024-02-21 (Type - Date)
field b -> 5 (Type - Integer)
I need to set (a-b) as a date in a field. This has to be done using BR which uses a scoped app table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 04:06 AM
Hi @Rush B
What is use case, if you provide more details, that will be good.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 04:14 AM
Sure , Example
field a -> 2024-02-21 (Type - Date)
field b -> 5 (Type - Integer)
I need to set (a-b) as a date in a field. This has to be done using BR which uses a scoped app table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 04:18 AM
Hi @Rush B
https://www.servicenow.com/community/developer-forum/subtract-days-from-date-time-field/m-p/1540493
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 05:20 AM
Hi @Rush B
You can use the script
var gdt = new GlideDateTime('fieldA'); //GlideDateTime to be used even if the type of field is date
gdt.addDaysLocalTime(fieldB * -1);
var newDate = gdt.getDate(); // use this newDate to save in the other field
Regards,
Piyush Sain