select now(); 
select current_timestamp; 
返回值均是当前年月日、时分秒,且秒保留6位小数,两种方式等价
select current_time; 
返回值:时分秒,秒最高精确到6位
select current_date; 
返回值:年月日
SELECT * FROM 表名 WHERE 时间字段 >= current_date AND 时间字段 < current_date + 1; SELECT * FROM 表名 WHERE 时间字段 >= current_date - 1 AND 时间字段 < current_date; SELECT * FROM 表名 WHERE 时间字段 >= current_date - interval '1 month' AND 时间字段 <= current_date; select date_trunc('DAY', 时间字段) as statisticTime, 分组字段, count(0) from 表名 GROUP BY date_trunc('DAY', 时间字段), 分组字段 日: DAY; 周: WEEK; 月: MONTH; 季度: QUARTER; 年: YEAR
select to_char( now() - interval '1 day','yyyy-mm-dd'); select to_char( now() - interval '1 week','yyyy-mm-dd hh:mi:ss'); select to_char( now() - interval '1 month','yyyy-mm-dd'); select to_char( now() - interval '1 year','yyyy-mm-dd'); select date_trunc('year', now()) select date_trunc('month', now()) select date_trunc('day', now()) select date_trunc('hour', now()) select date_trunc('minute', now()) select date_trunc('second', now()) select * from 表名 where timestamp_start >= current_timestamp - interval ' 1 seconds ' select * from 表名 where timestamp_start >= current_timestamp - interval ' 1 minutes' select * from 表名 where timestamp_start >= current_timestamp - interval ' 1 hours' select * from 表名 where timestamp_start >= current_timestamp - interval ' 1 day' select * from 表名 where timestamp_start >= current_timestamp - interval ' 7 day' select * from 表名 where timestamp_start >= current_timestamp - interval ' 1 month' select * from 表名 where timestamp_start >= current_timestamp - interval ' 1 year' select date_part('year', timestamp '2024-02-16 12:38:40') select date_part('month', timestamp '2024-02-16 12:38:40') select date_part('day', timestamp '2024-02-16 12:38:40') select date_part('hour', timestamp '2024-02-16 12:38:40') select date_part('minute', timestamp '2024-02-16 12:38:40') select date_part('second', timestamp '2024-02-16 12:38:40') select date_part('week', timestamp '2024-02-16 12:38:40')