greenplum 日期及时间函数及时间的加减
2017-10-17 12:17
267 查看
1.日期和时间间字段
date:日期字段,格式:2016-04-15
timestamp:时间字段,格式:2016-04-15 20:00:00
2.获取当时时间函数
select now();
select current_timestamp;
select CURRENT_TIME;
select LOCALTIME;
select LOCALTIMESTAMP;
3.获取当天日期
select current_date;
4.日期计算:
--使用interval
当前时间加2天
select now()+interval '2 day';
当前时间减2天
select now()-interval '2 day';
当前时间减1个月
select now()-interval '-2 mon';
当前时间减2小时
select now()+interval '2 hour';
5.时间截取
显示年
select extract(year from now());
显示月
select extract(mon from now());
6.时间转换
显示年月日时分秒
select timestamp '2012-05-12 18:54:54';
显示年月日
select date '2012-05-12 18:54:54';
显示年月日时分秒+毫秒
select TIMESTAMP WITH TIME ZONE '2012-05-12 18:54:54' ;
7.与unix时间戳的转换
SELECT TIMESTAMP 'epoch' + 1341174767 * INTERVAL '1 second';
相关文章推荐
- greenplum 日期及时间函数
- php 时间日期计算(加减)函数
- Oracle中日期时间的操作比较和加减-入门基础(转)
- ABAP 日期 时间 函数
- MySQL之——日期时间Extract函数介绍
- PostgreSQL 时间/日期 常用函数
- ORACLE中日期和时间函数汇总(转载)
- MYSQL常用日期和时间函数
- ASP.Net 获取服务器的当前日期时间的综合处理函数!
- (转转) SQL日期和时间函数
- mysql常用的日期加减函数与实例教程
- MySQL 日期时间计算函数
- java中关于时间日期操作的常用函数
- DB2中有关日期和时间的函数,及应用
- sqlserver日期、时间函数和格式
- C#时间日期操作函数
- Mysql日期和时间函数不求人(zz)
- 一个日期的扩展函数库包括计算周次和本周时间范围(javascript)
- python日期,时间函数
- postgresql数据库中判断是否是数字和日期时间格式函数