select EXTRACT(ISOYEAR FROM fromDate_) as year_, --取得周所在的年份 EXTRACT(WEEK FROM fromDate_) as week_, --取得周所在的年份 to_char(fromDate_ ,‘YYYYMMDD‘) as fromDate_, --周的起始日期 to_char(toDate_ ,‘YYYYMMDD‘) as toDate_ --周的结束日期 from ( select (date (curDate) - 7* weeks_) as fromDate_, (date (curDate) - 7* weeks_ + 6 ) as toDate_ from ( select generate_series(1,100) weeks_, -- 间隔周数(序列,这里取100周) cast(date_trunc(‘week‘, current_date) as character varying) as curDate -- 当前日期所在周的第一天 ) as fg
时间: 2024-10-29 15:03:47