Remove Time stamp from the updated field

shabbir9
Tera Contributor

Hi Team,

i am using sys_updated_on field in notification but time stamp is coming when i am using ${sys_updated_on} like this "2023-08-22 12:42:51" i want to remove time from this i have created mail script for this but its not working sharing the script can anyone help me in the script 

 

var updated = current.sys_updated_on;
var dateRE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\n/;
template.print(updated.replace(dateRE, ''));
})(current, template, email, email_action, event);
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@shabbir9 

you can use this in email script

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here
var gdt = new GlideDateTime(current.sys_updated_on);
var date = gdt.getLocalDate();
template.print(date);
})(current, template, email, email_action, event);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

5 REPLIES 5

Thanks @Ankur Bawiskar its working fine