selectnow();--2012-05-1218:51:59.562+08 selectcurrent_timestamp;--2012-05-1218:52:12.062+08 selectcurrent_date;--2012-05-12 selectcurrent_time;--18:53:23.234+08 selectlocaltimestamp;--timestampwithouttimezone
时间的计算(使用interval)
selectnow()+interval'2day';--2012-05-1420:05:32.796+082天后 selectnow()-interval'2day';--2012-05-1020:07:23.265+082天前 selectnow()+interval'2hour';--2012-05-1222:06:38.375+082小时后 .... interval可以不写,其值可以是 AbbreviationMeaning YYears MMonths(inthedatepart) WWeeks DDays HHours MMinutes(inthetimepart) ssec msmsec ususec
时间的截取(使用extract extract(interval,timestamp);)
selectextract(yearfromnow());--2012 selectextract(monfromnow());--55月份 ... interval值参考上面
时间的转换
selecttimestamp'2012-05-1218:54:54';--2012-05-1218:54:54 selectdate'2012-05-1218:54:54';--2012-05-12 selecttime'2012-05-1218:54:54';--18:54:54 selectTIMESTAMPWITHTIMEZONE'2012-05-1218:54:54' --2012-05-1218:54:54+08 --与unix时间戳的转换 SELECTTIMESTAMP'epoch'+1341174767*INTERVAL'1second'; --2012-07-0120:32:47原文链接:https://www.f2er.com/postgresql/194419.html