How to print date using email script in notification based on employment date for below condition

Adi13
Tera Contributor

Condition= Employment start Date + 30 days + The 1st of the next month. Ex.- Employment start Date=10 Sept +30 = 10 October so I want to print 1 November using an email script

6 REPLIES 6

Community Alums
Not applicable

Hi @Adi13 ,

Try below code for adding days:

 

 

 

var gdt = new GlideDateTime();

gdt.addDaysLocalTime(30);

current.datefield = gdt;

 

 

 

Note: add Days() is a deprecated method so try using addDaysLocalTime().

Ankur Bawiskar
Tera Patron
Tera Patron

you always want to add 30 days or 31 days?

what script did you try so far?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Always want to add 30 days and after added want to print 1 day of next month

 

Adi13
Tera Contributor

var empDate = employment_start_date.getValue();
var returnDate = new GlideDateTime(empDate);
returnDate.addDays(30);

var gdt = returnDate.getDate();
gdt.addMonths(1);

var gd = new GlideDate();
gd.setValue(gdt.toString());


template.print(gd.getByFormat("MM-1-yyyy"));