Netezza 中的滚动日期列表

Rolling list of dates in Netezza

类似于我问的一个问题 但与 Sybase SQL 相关,我正在寻找一个日期列表用于我的 where 子句以过滤 Netezza 中的 table。

目前,每次我 运行 使用手动日期查询时,我的 where 子句都需要更新,我希望自动执行此操作以使用最近 36 个月的数据,但从上个月的月底开始。因此,如果今天是 10/10/2018,我希望从 30/09/2018 倒退 36 个月。

我当前的 Netezza where 子句如下所示:

WHERE

    table.DateCol BETWEEN '2015-10-01' AND '2018-09-30'

我找到了一些关于提取月份的最后一天和第一天的示例 here,但我不知道如何使用 [=24= 将它们连接在一起以获取日期列表] 和 'AND'

--last_day(now() - interval'36 month') + interval '1 day'  
--last_day(now() - interval'1 month')

任何指点将不胜感激。

你在找这个吗?

where t.datecol between last_day(current_date - interval '36 month') + interval '1 day' and
                        last_day(current_date - interval '1 month')