我正在使用PostgreSQL 9.4。
我有一张表中的列名为timerange
,想要编写一个SELECT
查询,该查询将以两个单独的列time_start
和time_end
返回时间范围。
我尝试像处理数组一样处理它,但它不起作用:
select *, timerange[0] as t_start from schedules;
当前表格:
| id | timerange |
|----|-----------------------------------------------------|
| 1 | ["2017-05-05 19:00:00+02","2017-05-05 21:00:00+02") |
| 2 | ["2017-05-05 19:00:00+02","2017-05-05 21:00:00+02") |
所需表格:
| id | time_start | time_end |
|----|--------------------------|--------------------------|
| 1 | "2017-05-05 19:00:00+02" | "2017-05-05 21:00:00+02" |
| 2 | "2017-05-05 19:00:00+02" | "2017-05-05 21:00:00+02" |
["2017-05-05 14:00:00+02","2017-05-05 15:00:00+02")
中,我得到的t_start
等于2017-05-05 14:00:00.000000
。 - veich