--从周日开始,且周日为1,1~7
SELECT to_char('2020-05-03'::timestamp, 'D');
SELECT to_char('2020-05-04'::timestamp, 'D');
SELECT to_char('2020-05-05'::timestamp, 'D');
SELECT to_char('2020-05-06'::timestamp, 'D');
SELECT to_char('2020-05-07'::timestamp, 'D');
SELECT to_char('2020-05-08'::timestamp, 'D');
SELECT to_char('2020-05-09'::timestamp, 'D');
SELECT to_char('2020-05-10'::timestamp, 'D');
--从周日开始,且周日为0,0~6
SELECT extract(DOW FROM '2020-05-03'::timestamp);
SELECT extract(DOW FROM '2020-05-04'::timestamp);
SELECT extract(DOW FROM '2020-05-05'::timestamp);
SELECT extract(DOW FROM '2020-05-06'::timestamp);
SELECT extract(DOW FROM '2020-05-07'::timestamp);
SELECT extract(DOW FROM '2020-05-08'::timestamp);
SELECT extract(DOW FROM '2020-05-09'::timestamp);
SELECT extract(DOW FROM '2020-05-10'::timestamp);
--获取当前日期为星期几,周日为0,0~6
SELECT extract(DOW FROM NOW());
--获取当前日期为一天的第几个小时
SELECT extract(HOUR FROM NOW());
--获取当前日期为月份的第几天
SELECT extract(DAY FROM NOW());
--获取当前日期为一年的第几个月份
SELECT extract(MONTH FROM NOW());
--获取当前时间的小时
SELECT to_char(current_timestamp, 'HH');
--当前日期为星期几,周日为1,1~7
SELECT to_char(current_timestamp, 'D');
--当前日期为月份的第几天
SELECT to_char(current_timestamp, 'DD');
--当前日期为年份的第几天
SELECT to_char(current_timestamp, 'DDD');