0

I am stuck trying to convert the following strings formatted like this 26-09-2021-02-54-03 (DD-MM-YYYY-hh-mm-ss) into timestamp or in this format YYYY-MM-DD HH:DD:SS in BigQuery. Any idea how to process?

I cannot use PARSE_TIMESTAMP() since there is no T in the string.

Thank you

1 Answer 1

1

You should be able to parse it with the following:

select '26-09-2021-02-54-03'
    , PARSE_TIMESTAMP("%d-%m-%Y-%H-%M-%S", '26-09-2021-02-54-03')
    , FORMAT_TIMESTAMP("%F %X",PARSE_TIMESTAMP("%d-%m-%Y-%H-%M-%S", '26-09-2021-02-54-03'))

For more information on the format elements see: https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions#supported_format_elements_for_timestamp

Sign up to request clarification or add additional context in comments.

Comments

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.