GreenPlum常用时间函数

GreenPlum中常用时间函数如下:
这里写图片描述
这里写图片描述

测试代码:

eda_gp=> select age('20160114','19911008');
          age           
------------------------
 24 years 3 mons 6 days
(1 row)

eda_gp=> select age(timestamp '19911008');
          age           
------------------------
 24 years 3 mons 6 days
(1 row)

eda_gp=> select current_date;
    date    
------------
 2016-01-14
(1 row)

eda_gp=> select current_time;
       timetz       
--------------------
 10:22:30.776267+08
(1 row)

eda_gp=> select current_timestamp;
             now              
------------------------------
 2016-01-14 10:22:38.77006+08
(1 row)

eda_gp=> select date_part('hour',timestamp'20160114 10:07:30');
 date_part 
-----------
        10
(1 row)

eda_gp=> 
eda_gp=> select date_part('minute',timestamp'20160114 10:07:30');
 date_part 
-----------
         7
(1 row)

eda_gp=> select date_part('second',timestamp'20160114 10:07:30');
 date_part 
-----------
        30
(1 row)

eda_gp=> select date_trunc('hour',timestamp'20160114 10:07:30');
     date_trunc      
---------------------
 2016-01-14 10:00:00
(1 row)

eda_gp=> select date_trunc('minute',timestamp'20160114 10:07:30');
     date_trunc      
---------------------
 2016-01-14 10:07:00
(1 row)

eda_gp=> select date_trunc('second',timestamp'20160114 10:07:30');
     date_trunc      
---------------------
 2016-01-14 10:07:30
(1 row)

eda_gp=> select extract(hour from timestamp '20160114 10:07:30');
 date_part 
-----------
        10
(1 row)

eda_gp=> select now();
              now              
-------------------------------
 2016-01-14 10:26:51.572545+08
(1 row)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值