GBase 8c
其他
文章

GBase 8c兼容Oracle的 data 类型

发表于2023-12-07 14:50:2412次浏览0个评论

GBase 8c兼容Oracle的 data 类型,但二者DATE数据类型返回值是不同的,所以如果您想使用基于Oracle的DATE数据类型,请声明oracle.date,具体参见如下示例:

GBase 8c:

  SELECT add_months(date '2005-05-31',1);  -- > 2005-06-30

  SELECT last_day(date '2005-05-24');      -- > 2005-05-31

  SELECT next_day(date '2005-05-24', 'monday'); -- > 2005-05-30

  SELECT next_day(date '2005-05-24', 2); -- > 2005-05-30

  SELECT months_between(date '1995-02-02', date '1995-01-01'); -- > 1.0322580645161

  SELECT trunc(date '2005-07-12', 'iw');   -- > 2005-07-11

  SELECT round(date '2005-07-12', 'yyyy'); -- > 2006-01-01

Oracle生态:

 SELECT oracle.add_months(oracle.date'2005-05-31 10:12:12',1); -- > 2005-06-30 10:12:12

 SELECT oracle.last_day(oracle.date '2005-05-24 11:12:12'); -- > 2005-05-31 11:12:12

 SELECT oracle.next_day(oracle.date '2005-05-24 10:12:12', 'monday'); -- > 2005-05-30 10:12:12

 SELECT oracle.next_day(oracle.date '2005-05-24 11:21:12', 1); -- > 2005-05-29 11:21:12

 SELECT oracle.months_between(oracle.date '1995-02-02 10:00:00', oracle.date '1995-01-01 10:21:11'); -- > 1.03225806451613

 SELECT oracle.to_date('02/16/09 04:12:12', 'MM/DD/YY HH24:MI:SS'); -- > 2009-02-16 04:12:12

评论

登录后才可以发表评论