获取系统时间函数
select now(); --2013-11-28 16:20:25.259715+08
select current_timestamp; --2013-11-28 16:20:38.815466+08
select current_date; --2013-11-28
select current_time; --16:21:08.981171+08
时间的计算
select now()+interval '2 day'; --2013-11-30 16:21:47.610118+08 2天后
select now()-interval '2 day'; --2013-11-26 16:22:03.390593+08 2天前
select now()+interval '2 hour'; --2013-11-28 18:22:14.578733+08 2小时后
-- interval可以不写,其值可以是
-- Abbreviation Meaning-- Y Years
-- M Months (in the date part)
-- W Weeks
-- D Days
-- H Hours
-- M Minutes (in the time part)
--时间的截取
--使用extract extract(interval,timestamp);
select extract(year from now()); --2013
select extract(mon from now()); --5月份
--时间的转换
select timestamp '2012-05-12 18:54:54'; --2012-05-12 18:54:54
select date '2012-05-12 18:54:54'; --2012-05-12
select time '2012-05-12 18:54:54'; --18:54:54
select TIMESTAMP WITH TIME ZONE '2012-05-12 18:54:54' --2012-05-12 18:54:54+08
SELECT TIMESTAMP 'epoch' + 1341174767 * INTERVAL '1 second';
--2012-07-01 20:32:47