PostgreSQL的时间函数使用
发布时间:2020-12-13 17:04:15 所属栏目:百科 来源:网络整理
导读:获取系统时间函数 selectnow();--2012-05-1218:51:59.562+08selectcurrent_timestamp;--2012-05-1218:52:12.062+08selectcurrent_date;--2012-05-12selectcurrent_time;--18:53:23.234+08selectlocaltimestamp;--timestampwithouttimezone 时间的计算(使用i
获取系统时间函数 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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |