We have a workflow that pushes email content into Coda. We need the dates of the original emails, not ‘creation date’ and so we use one of the email headers for that. Unfortunately, each SMTP service uses its own date stamp. We are wrestling with dates in the form of “January DD…”. In order to parse these into a Coda date type, the Month name needs to be replaced with Month number, and there’s no function for that. I’m hoping that someone has a more simple way of converting other than writing a Pack. This is one I’ve come up with so far:
The following parses “June 7, 2022 at 5:27:25 PM PDT” into ‘2022-06-07 5:58 PM’ (with YYYY-MM-DD formatting)
If(IsDate(thisRow.date),thisRow.date ,
Concatenate(
20,
RegexReplace(thisRow.date,"^.*?, 20(\d{2}).*$" , "$1"),
"-",
switch(true,
regexmatch(thisRow.date,"Jan|January"),"01",
regexmatch(thisRow.date,"Feb|February"),"02",
RegexMatch(thisRow.date,"Mar|March"),"03",
RegexMatch(thisRow.date,"Apr|April"),"04",
RegexMatch(thisRow.date,"May"),"05",
RegexMatch(thisRow.date,"Jun|June"),"06",
RegexMatch(thisRow.date,"Jul|July"),"07",
RegexMatch(thisRow.date,"Aug|August"),"08",
RegexMatch(thisRow.date,"Sep|September"),"09",
RegexMatch(thisRow.date,"Oct|October"),"10",
RegexMatch(thisRow.date,"Nov|November"),"11",
RegexMatch(thisRow.date,"Dec|December"),"12"
),
"-",
RegexReplace(thisRow.date,"^\w{3,9} (\d+).*$" , "$1"),
RegexReplace(thisRow.date,"^.*? at(.* ).*$" , "$1")
)
)
Interestingly, there is a “January 21, 2022” date format, but Coda doesn’t seem to recognize textual dates as a date type.
The above works for our particular use case, but only for the particular format passed.
Any thoughts appreciated.