The CreatorCon Call for Content is officially open! Get started here.

set date format in a notification via email script

Amit Dey1
Tera Contributor

Hi I have a requirement to print created on date + 89 days in this format "02-Nov-2023" , but in notification it is printing like this 2023-06-04(yyyy-MM-dd)

so below is the email script I developed 

Thanking you in advance ...

 

var nd = new GlideDateTime(current.sys_created_on);
    var fd = new GlideDateTime(nd);
    fd.addDaysLocalTime(89);

	var dateToPrint = fd.getDate();
    template.print(dateToPrint.toString());

 

 

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

Here is the sample script to print the format. Use getByFormat('dd-MMM-YYY') method

 


var gr = new GlideRecord("incident");
gr.addQuery("sys_id","148c06499790b110df5db8a3f153af64");
gr.query();
while(gr.next())
{
var nd = new GlideDateTime(gr.sys_created_on);
var fd = new GlideDateTime(nd);
fd.addDaysLocalTime(89);

var dateToPrint = fd.getDate();
gs.print(dateToPrint.getByFormat('dd-MMM-YYY'));
}

HarishKM_0-1691129564226.png

 

Regards
Harish

View solution in original post

2 REPLIES 2

Harish KM
Kilo Patron
Kilo Patron

Here is the sample script to print the format. Use getByFormat('dd-MMM-YYY') method

 


var gr = new GlideRecord("incident");
gr.addQuery("sys_id","148c06499790b110df5db8a3f153af64");
gr.query();
while(gr.next())
{
var nd = new GlideDateTime(gr.sys_created_on);
var fd = new GlideDateTime(nd);
fd.addDaysLocalTime(89);

var dateToPrint = fd.getDate();
gs.print(dateToPrint.getByFormat('dd-MMM-YYY'));
}

HarishKM_0-1691129564226.png

 

Regards
Harish

Yes it worked..thanks