Home > Back-end >  Convert STRING with date text and numbers in BigQuery into DATETIME
Convert STRING with date text and numbers in BigQuery into DATETIME

Time:11-30

I Want to parse or cast the following column which is the format of this example STRING:

18 Apr 2016 10:17:50

into one new column as a DATETIME in this format:

YYYY-MM-DDTHH:MM:SS

So the above would read as an example of one of the thousands of rows:

2016-04-18T10:17:50

I'm not sure what's throwing this one off but I either get a column full of nulls or a message saying:

Mismatch between format character ':' and string character ' '

I've tried parse_Datetime and safe.parsed_datetime with the correct syntax and format elements as well as casting. I'm obviously doing something wrong.

CodePudding user response:

use PARSE_DATETIME you find there also more parameters

SELECT PARSE_DATETIME("%d %b %Y %T", "18 Apr 2016 10:17:50") as dt
  • Related