- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi all,
I need to print out the format of a date in DD/MM/YYYY format. So far I have this but it doesn't work, can someone point me in the direction of what is missing?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
this should work
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var nd = new GlideDateTime();
nd.addDaysLocalTime(16);
var date = nd.getDate();
var dtObj = new GlideDate();
dtObj.setValue(date);
var dateFormatted = dtObj.getByFormat('dd/MM/yyyy');
template.print(dateFormatted);
})(current, template, email, email_action, event);
Background Script:
var nd = new GlideDateTime();
nd.addDaysLocalTime(16);
var date = nd.getDate();
var dtObj = new GlideDate();
dtObj.setValue(date);
var dateFormatted = dtObj.getByFormat('dd/MM/yyyy');
gs.info(dateFormatted);
Working Output:
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
this should work
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var nd = new GlideDateTime();
nd.addDaysLocalTime(16);
var date = nd.getDate();
var dtObj = new GlideDate();
dtObj.setValue(date);
var dateFormatted = dtObj.getByFormat('dd/MM/yyyy');
template.print(dateFormatted);
})(current, template, email, email_action, event);
Background Script:
var nd = new GlideDateTime();
nd.addDaysLocalTime(16);
var date = nd.getDate();
var dtObj = new GlideDate();
dtObj.setValue(date);
var dateFormatted = dtObj.getByFormat('dd/MM/yyyy');
gs.info(dateFormatted);
Working Output:
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Big thanks Ankur, that's worked perfectly.
