使用系统日期过滤

问题描述 投票:0回答:1

运行SQL查询以获取具有给定范围内的日期的数据。 stdt是日期数据类型。这是有问题的代码:

    select hofc_wrk_unit_uid
    from mhal_rep.stusha
    where STDT BETWEEN date('2010-01-21') AND to_char(SYSDATE, 'YYYY-MM-DD')
    and ibmsnap_operation not in ('D')
    and stus_cd in ('CLSD')

我一直收到错误“列'SYSDATE'不存在”

如何让它调用SYSDATE函数并停止查找名为sysdate的列?

试过这个:

    select hofc_wrk_unit_uid
    from mhal_rep.stushh
    where STDT BETWEEN date('2010-01-21') AND SYSDATE()
    and stus_endt BETWEEN date('2010-01-21') AND SYSDATE()
    and stus_cd in ('DWPC')
    and ibmsnap_operation not in ('D')

并且我正在获取函数sysdate()不存在

sql greenplum
1个回答
0
投票

请尝试以下方法:

select hofc_wrk_unit_uid
    from mhal_rep.stushh
    where STDT BETWEEN date('2010-01-21') AND current_date
    and stus_endt BETWEEN date('2010-01-21') AND current_date
    and stus_cd in ('DWPC')
    and ibmsnap_operation not in ('D')
© www.soinside.com 2019 - 2024. All rights reserved.