PostgreSQL-获取日期时间、截取年、月、日

一、获取系统时间函数

1.1 获取当前完整时间

select now();

select current_timestamp;      --也是一样的效果

1.2 获取当前日期

select current_date;

1.3 获取当前时间

select current_time;

时间字段的截取

取年份

select extract(year from now());

取月份

select extract(month from now());

取给定的时间的日期

select extract(day from timestamp '2013-04-13');

标签:PostgreSQL 发布于:2019-10-20 10:53:15