Quelques exemples permettant de calculer des écarts de dates. Le résultat est donné sous la forme « yyyymmdd » (ex 20191201)
Date du jour – 2 jours :
with tmp as (
SELECT CURRENT DATE – 2 DAYS as dat
FROM SYSIBM/SYSDUMMY1)
select year(dat) * 10000 + month(dat) * 100 + day(dat)
from tmp
Date du jour + 12 mois :
with tmp as (
SELECT CURRENT DATE + 12 MONTH as dat
FROM SYSIBM/SYSDUMMY1)
select year(dat) * 10000 + month(dat) * 100 + day(dat)
from tmp
Date du jour – 3 ans :
with tmp as (
SELECT CURRENT DATE -3 YEAR as dat
FROM SYSIBM/SYSDUMMY1)
select year(dat) * 10000 + month(dat) * 100 + day(dat)
from tmp