1.日期和时间间字段
date:日期字段,格式:2020-04-15timestamp:时间字段,格式:2020-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 '-1 mon';当前时间减2小时 select now()+interval '2 hour';
5.时间截取
显示年select extract(year from now()); 显示月select extract(mon from now());
6.时间转换
显示年月日时分秒select timestamp '2020-04-15 18:54:54';显示年月日select date '2020-04-15 18:54:54'; 显示年月日时分秒+毫秒select TIMESTAMP WITH TIME ZONE '2020-04-15 18:54:54' ;