79458532

Date: 2025-02-21 20:17:34
Score: 1
Natty:
Report link

Use parse_datetime and format_datetime along with the proper formatting elements.

-- get a datetime
select parse_datetime(
  '%m/%d/%Y %T %p',
  '4/25/2016 09:37:35 AM'
)
;
-- 2016-04-25T09:37:35 (string representation)

Note that a datetime doesn't have a timezone. To include a timezone, you would use timestamp.

-- get a timestamp
select parse_timestamp(
  '%m/%d/%Y %T %p',
  '4/25/2016 09:37:35 AM',
  'UTC'
)
;
-- 2016-04-25 09:37:35 UTC (string representation)

-- get the string representation you specified
select format_timestamp(
  '%F %T %Z',
  parse_timestamp(
    '%m/%d/%Y %T %p',
    '4/25/2016 09:37:35 AM',
    'UTC'
  )
)
;
-- 2016-04-25 09:37:35 UTC
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: gmw