Home > Enterprise >  Converting a STRING to a TIMESTAMP
Converting a STRING to a TIMESTAMP

Time:07-07

I apologize if this is an easy ask, I'm still a bit new to SQL.

I'm currently using BigQuery and I have a column of date strings that look like "2022-03-22T00:23:30.000Z" that I am trying to convert to a TIMESTAMP data type so that I can use operators to compare it to CURRENT_TIMESTAMP(). I've tried breaking it into a substring to remove the final 0 and 'Z', then converting to a TIMESTAMP, but I'm either doing it wrong or its the wrong way to go about it. I've also tried PARSE_TIMESTAMP, but it 'fails to parse input string'. Any help would be appreciated, thanks!

CodePudding user response:

TIMESTAMP(string_expression[, time_zone])

TIMESTAMP("2022-03-22T00:23:30.000Z", "UTC")

Resource: https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions

Hoped that helped.

  • Related