Date Time functions

Aswin Chandras1
Tera Contributor

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

4 REPLIES 4

Gaurav Bajaj
Kilo Sage

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


Jaspal Singh
Mega Patron
Mega Patron

Hi Aswin,



Link https://community.servicenow.com/thread/166458 should help.


  1. var gdt = current.u_last_test_date.getGlideObject();  
  2. if(current.business_criticality=='1 - Critical'){  
  3.   current.u_next_test_date=gdt.addDays(182); //adding 182 days to last tested date  
  4. }  

Stewe Lundin
Mega Guru

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.