tandem
tandem

Reputation: 2238

Bigquery convert string to datetime

I'm trying to parse a string to a datetime format. I am posting here after exploring this answer

Here is my attempt at it, what am i missing?

select PARSE_TIMESTAMP('%Y-%M-%dT%H:%M:%S.000000', StartDate) AS parsedStartDate

This is the error I get: Failed to parse input string "2020-11-23T10:51:47.5533333"

Upvotes: 0

Views: 208

Answers (1)

Kyrylo Bulat
Kyrylo Bulat

Reputation: 800

Try the following in standard SQL:

with data as (
select '2020-11-23T10:51:47.5533333' as StartDate
)
select PARSE_TIMESTAMP('%Y-%m-%dT%H:%M:%E*S',StartDate) from data;

Upvotes: 1

Related Questions