代码之家  ›  专栏  ›  技术社区  ›  TheGoat

Netezza日期滚动列表

  •  1
  • TheGoat  · 技术社区  · 6 年前

    here 但与sybasesql相关,我希望获得where子句的日期列表,以过滤Netezza中的表。

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

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

    我找到了一些例子 here 关于提取一个月的最后一天和第一天,但我不知道如何使用'BETWEEN'和'and'将它们连接在一起得到一个日期列表

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

    任何指点都将不胜感激。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Gordon Linoff    6 年前

    你在找这个吗?

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