0

I have a time stemp formated as a string like this: 2022_05_26_13_52_05 which is format as YYYY_MM_DD_hh_mm_ss how can I use BigQuery PARSE_TIMESTAMP to parse it? I try it with

SELECT PARSE_TIMESTAMP("%Y_%m_%d_%I_%M_%S", "2022_05_26_13_52_05") from `Something.test.my_table_name_*`

It fails at: Failed to parse input string "2022_05_26_13_52_05", but if I only parse PARSE_TIMESTAMP("%Y_%m_%d", "2022_05_26"). It works perfectly fine. Many thanks!

1 Answer 1

2

try below instead

PARSE_TIMESTAMP("%Y_%m_%d_%H_%M_%S", "2022_05_26_13_52_05")    

with result

2022-05-26 13:52:05 UTC
Sign up to request clarification or add additional context in comments.

2 Comments

Hi Mikhail, it works perfectly fine. Looks like, I put %I for wrong hour format. Thanks a lot
sure. yes - this was the only wrong piece :o)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.