How would I convert the following AM/PM value to the 24-hour clock time in Big Query standard SQL?
created_date 8/30/2018 2:23:38 PM
created_date 2018-08-30 14:23:38 UTC
First parse the timestamp string as a TIMESTAMP value, then format it in the desired way:
SELECT
FORMAT_TIMESTAMP(
'%Y-%m-%d %H:%M:%S %Z',
PARSE_TIMESTAMP('%m/%d/%Y %I:%M:%S %p', created_date)
) AS created_date
FROM (
SELECT '8/30/2018 2:23:38 PM' AS created_date
);
+-------------------------+
| created_date |
+-------------------------+
| 2018-08-30 14:23:38 UTC |
+-------------------------+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With