How to show todays date in the subject of email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2019 07:09 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2019 07:11 AM
Q: What is the business requirement here? All email have a "Date" field in the header so I'm curious what the value of adding it to the subject would be?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2019 07:16 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2019 07:15 AM
I did some quick testing to satisfy my own curiosity - it turns out you cannot run ${mail_script:script_name} in the subject. Given that you CAN use the field meta strings, I recommend taking a value from a field like ${sys_updated_on} to put the current date in the field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 08:56 AM - edited 11-04-2022 08:58 AM
New response to an older thread here. I recently dealt with this subject line/date scenario on notifications, and came across this thread while searching for a solution. Figured I'd share what I came up with.
While you cannot run a mail script directly in the subject line, you can use a mail script to set the subject, which is what I did to achieve a similar requirement. You also need a script include to get the date value.
Mail script line required
email.subject = 'Subject line text goes here | ' + nowDateOnly();
nowDateOnly() script include - there may already be an out of the box include/function that you can use, but this is one we threw together a while back and have reused for various things like our Scheduled Reports subject line and now on notifications. It's pretty simple and straightforward.
function nowDateOnly() {
var dateTime = gs.nowDateTime().split(' ');
return dateTime[0];
}
You can also use the script include via an inline JavaScript call in the Subject field on a Scheduled Report. Only drawback in this use case is the javascript and function() calls count against your subject line character limit. Works great for short subject lines on scheduled reports. (replace &colon with the actual char, the editor did that)
javascript:"Subject line text goes here | " + nowDateOnly()
As far as our use case goes, this originally came up when folks wanted to see the date in the subject line for sorting purposes, to help easily differentiate at a glance when sorting by Subject in Outlook, etc.
Good Luck!
-Daniel