For Redshift
I have strings like "1:00 PM - 9:15 PM" in a column called workhours
.
What's the most efficient way in SQL to convert this type of string in this column to two columns (start time, end time), resembling something like :
start_time | end_time
13:00 21:15
I know the first step is start with:
select
split_part(workhours, '-', 1) as start_time,
split_part(workhours, '-', 2) as end_time
but from here, what's the best way to turn the "1:00PM" into "13:00" and the "9:15PM" into "21:15"?
Edit: I would also like the solution to be able to automatically accommodate both AM and PM without me having to manually specific which (hope that makes sense).
Thanks in advance!