Date Time functions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2017 01:38 AM
Hi,
I want to add the next 7 days from the current date in my scheduled job using script.
Please let me know the function.
var added_day = chg.u_last_login_mail + 7 days;
if(added_day == gs.nowDateTime())
Here I want to add the seven days.
I am updating the last login mail with the current date.
From that I need to wait for 7 days
Thanks,
Aswin C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2017 01:41 AM
Hi Ashwin,
Try below script.
var lastloginmail = new GlideDateTime(chg.u_last_login_mail.getGlideObject());
lastloginmail=lastloginmail.addDaysUTC(7);
if(lastloginmail== gs.nowDateTime())
Please mark correct/helpful based on the impact of the response.
Thanks
Gaurav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2017 01:42 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2017 01:44 AM
Hi Aswin,
Link https://community.servicenow.com/thread/166458 should help.
- var gdt = current.u_last_test_date.getGlideObject();
- if(current.business_criticality=='1 - Critical'){
- current.u_next_test_date=gdt.addDays(182); //adding 182 days to last tested date
- }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2017 01:47 AM
Check out gs.daysAgo(int)
http://wiki.servicenow.com/index.php?title=GlideSystem_Date_and_Time_Functions#daysAgo.28int.29
var dateSevenDayAgo = gs.daysAgo(7);
You will get det date from seven days ago in the format yyyy-mm-dd hh:mm:ss.