1
我在PostgreSQL中定义了一个类型为daterange的表,现在需要将它分成两列类型为date(开始日期和结束日期)。我怎么能这样做,我无法找到任何东西。将日期范围拆分为列
例如,我在[2012-01-01,2015-10-10)列时间段内需要:start_date 2012-01-01和end_date 2015-10-10。
我在PostgreSQL中定义了一个类型为daterange的表,现在需要将它分成两列类型为date(开始日期和结束日期)。我怎么能这样做,我无法找到任何东西。将日期范围拆分为列
例如,我在[2012-01-01,2015-10-10)列时间段内需要:start_date 2012-01-01和end_date 2015-10-10。
lower
和upper
https://www.postgresql.org/docs/9.6/static/functions-range.html
create table t (period daterange);
insert into t (period) values ('[2012-01-01,2015-10-10)');
select (period).lower
,(period).upper
from t
;