Convert Text to Date

I have the data in one column:

2018-11-08 10:21:59 PST
2019-02-26 07:26:44 PST
2019-02-04 08:08:18 PST
2019-03-11 07:47:03 PDT

This is now a text field, how can I convert this to a date field ? I will will use a new column but what is the Formula to use?

What is the formula to use here

You’ll use the DATETIME_PARSE function for this. However, the PST vs PDT difference can’t be tracked, as the date format specifiers used by this function don’t provide that kind of control.

Assuming your existing text-based dates are in a {Date} column, I originally wrote this formula:

DATETIME_PARSE(Date, "YYYY-MM-DD hh:mm:ss")

However, sometimes Airtable is smart enough to figure things out on its own:

DATETIME_PARSE(Date)

In either case, everything works fine:

26%20PM

1 Like

Nops I was unable to do it with this column alone

I did have to add 2 new columns:

open-date (Fixer): : DATETIME_FORMAT({open-date},“MM/DD/YYYY HH:mm:ss”)
Date Added:: DATETIME_PARSE({open-date (Fixer)})

Airtable catch that I want date after I did 2 columns

WHy?

Not sure. DATETIME_PARSE by itself worked fine for me on the samples I copied from your original post. It could be that there’s something in the actual data you’re using that’s muddying the waters, and it can’t parse correctly.

What’s the order of your two fields? Does the format come first, and then the parse (as you have them written), or the other way around? Technically formatting is only possible on an actual datetime object, so formatting text before it’s been turned into a datetime object should (in theory) not work. It should be parse first, then format.

One thing that can sometimes throw Airtable off its game is styling of certain characters. It’s known that styled quotes won’t work in formulas, so maybe some of the characters in your text version of the dates can’t be parsed accurately. Did you copy your original example directly from the data itself, or retype it?

@Justin_Barrett I have another similar issue. I auto-import data from Twitter into Airtable through IFTTT. The date has to come in as plain text (i.e., Long Text). Its comes in as this: August 04, 2019 at 04:04AM

I want to convert that to: 2019-Aug-04 OR 2019-08-04

What formula can I use in Airtable? DATETIME_PARSE(Date,“YYYY-MM-DD”) didn’t work in this case. The formula itself ‘took’ but the “August 04, 2019 at 04:04AM” converted to “Error”

Welcome to the community, Callie! :smiley: With the DATETIME_PARSE() function, the pattern that you give it is the one matching the string you’re parsing, which is “August 04, 2019 at 04:04AM” in your case:

DATETIME_PARSE(Date, "MMMM DD, YYYY at hh:mmA")

What you get back is a datetime object, which then needs to be formatted using DATETIME_FORMAT(). The whole thing will look like this, using your first desired format (2019-Aug-04) as an example:

DATETIME_FORMAT(DATETIME_PARSE(Date, "MMMM DD, YYYY at hh:mmA"), "YYYY-MMM-DD")

04%20AM

1 Like