Nov 08, 2022 02:07 PM
Hello,
I’m building an Automation in Airtable and am using the “at a scheduled time” trigger and the “send an email” action.
In the “send an email” action, in the email subject line, I’d like to include the “actual trigger time”.
However, the time includes the date and timezone code, and I’d like to remove the timezone code.
As an example, here’s what I want the email subject line to say:
“Weekly Sales Report - 2022-11-08”.
But instead it looks like this: “Weekly Sales Report - 2022-11-08T22:51:31.571Z”. Is it possible to strip out the timezone code (T22:51:31.571Z)? Or can someone suggest an alternative solution?
Thanks so much!
Nov 08, 2022 03:25 PM
Hey there Paul!
There are a few ways you can do this, my personal preference is to use a Script action in the automation because it’s the simplest to integrate and you don’t have to worry about relying on fields etc.
Here are the steps to achieve what you’re looking for:
let today = new Date();
const [currentDate] = today.toISOString().split('T');
output.set('todaysdate',currentDate);
Hopefully that works for you!
Kyle
Nov 08, 2022 03:28 PM
@Paul_Matsushima Unfortunately, Airtable’s Automations always use that timezone code.
The non-scripting way of working around this is to create a formula field in your base (using the DATETIME_FORMAT
function) to create a text string.
Then, you can insert that formula field into the subject of your email.
It’s kind of a pain because it creates extra clutter in your base, but it will do the trick.
Nov 08, 2022 03:41 PM
Thanks @KVachon. I tried the script and it ran perfectly! That did the job for me.
And thanks @ScottWorld for the advice. Yeah, I was trying to avoid adding a new field in my base as I didn’t want to clutter it up.