gpt4 book ai didi

sql - 将日期范围拆分为列

转载 作者:行者123 更新时间:2023-11-29 12:56:50 24 4
gpt4 key购买 nike

我在 PostgreSQL 中定义了一个表,其中有一列 daterange 类型,现在需要将其拆分为两列 date 类型(开始日期和结束日期)。我该怎么做,我找不到任何东西。

例如,我有 [2012-01-01,2015-10-10) 列期间并且需要:start_date 2012-01-01 和 end_date 2015-10-10。

最佳答案

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
;

关于sql - 将日期范围拆分为列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41091917/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com