DB2获取查询日期往前推26个每个周五的日期
DB2的函数写不来
但可以用帆软函数 把today()改成你的查询日期就行了
DATEDELTA(DATEINWEEK(TODAY(),5),-182)
补充
MAPARRAY(range(DATEDELTA(DATEINWEEK(TODAY(),5),-182),DATEINWEEK(TODAY(),5),7),FORMAT(ITEM,'yyyy-MM-dd'))
SELECT
TO_CHAR(TO_DATE('2022-04-13','YYYY-MM-DD') -T1.NUM,'YYYYMMDD') DT_SNAP
FROM
SYSIBM.DUAL,
(
NUM
FROM (
ROW_NUMBER() OVER(ORDER BY (VALUES 1)) AS NUM
SYSIBM.SYSDUMMY1,
SYSIBM.SYSCOLUMNS
FETCH FIRST 182 ROWS ONLY
) T
UNION ALL
SELECT 0 AS NUM FROM SYSIBM.DUAL
)T1
WHERE
DAYNAME(TO_CHAR(TO_DATE('2022-04-13','YYYY-MM-DD') -T1.NUM,'YYYY-MM-DD')) = 'Friday'
ORDER BY
DT_SNAP DESC
LIMIT 26