- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 04:09 AM
Hi All,
Can someone please help me to add the logic to add 'n' plus days to a date field and format it to YYYY-MM-DD format?
Code:::
---------
var date = new Date();
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
var lastDayOfMonth = lastDay.getFullYear() + "-" +((lastDay.getMonth()+1).length != 2 ? "0" + (lastDay.getMonth() + 1) : (lastDay.getMonth()+1)) + "-" + lastDay.getDate()
var gr1 = new GlideRecord('x_inpe_gbs_inf_gbs_infrastructure_roles');
gr1.query();
while(gr1.next()){
var projectedHireDate = gr1.getDisplayValue('projected_hire_date');
if (projectedHireDate < lastDayOfMonth){
//projectedHireDate = ( projectedHireDate + 90Days ) into YYYY-MM-DD format
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 05:59 AM
Hello @chatsaurav19
Modify the below line with that script.
var endDate = gdt.getDate();
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 06:21 AM
Hello @chatsaurav19
As per the new rules of Community you can mark Multiple solution as Accept,
Can you mark above response as Accept which has the complete script, i have modified that line in original response, by doing so it will help other users to find the solution as well.
Thanks,
Samaksh Wani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 05:13 AM
Hello @chatsaurav19
Greetings!
you can try addDays
var date = new GlideDateTime(dt);
date.addDays(14);
If my response helped please mark it correct and helpful.
Kind Regards,
Ravi Chandra.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 05:39 AM
Hi @Ravi Chandra_K It did work but I need to remove the Time Format attached ( 00:00:00 ).
2023-08-30 00:00:00
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 05:20 AM
Hello @chatsaurav19
Add this code in your if Statement
var gdt = new GlideDateTime(projectedHireDate);
gdt.addDaysLocalTime(7);
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 05:40 AM
Hi @Samaksh Wani It also worked but I need to remove the time stamp ( 00:00:00 )
2023-08-30 00:00:00