Crystal命令对象参数选择多个日期范围?

时间:2015-02-09 15:20:38

标签: sql date crystal-reports

我正在尝试为我预定义的日期范围(字符串)设置一个命令对象参数,输入该参数以选择要使用的日期范围。我做错了什么?

我的where语句在我的Crystal 2013命令对象中看起来像这样(注意:这是命中Oracle PL / SQL数据库)

WHERE 
({?PredefinedDateRange} = 'yesterday' AND H.HOSP_DISCH_TIME between trunc(sysdate-1) and trunc(sysdate))
or
({?PredefinedDateRange} = 'lastweek' AND H.HOSP_DISCH_TIME between next_day(sysdate,'SUN')-14 and next_day(sysdate,'SAT')-7)
or
({?PredefinedDateRange} = 'lastmonth' AND H.HOSP_DISCH_TIME between add_months(trunc(sysdate,'mm'),-1) and last_day(add_months(trunc(sysdate,'mm'),-1)))
or
({?PredefinedDateRange} = 'lastquarter' AND H.HOSP_DISCH_TIME between ADD_MONTHS(TRUNC(SYSDATE,'Q'),-3) and TRUNC(SYSDATE,'Q') - 1)
or
({?PredefinedDateRange} = 'lastyear' AND H.HOSP_DISCH_TIME between TRUNC(TRUNC(SYSDATE,'Year')-1,'Year') and LAST_DAY(ADD_MONTHS(TRUNC(TRUNC(SYSDATE,'Year')-1,'Year'),11)))
or
({?PredefinedDateRange} = 'currentquarter' AND H.HOSP_DISCH_TIME between TRUNC(SYSDATE,'Q') and LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE,'Q'),2)))
or
({?PredefinedDateRange} = 'rollingyear' AND H.HOSP_DISCH_TIME between trunc(sysdate-365) and trunc(sysdate))

0 个答案:

没有答案