0

我正在使用 Cognos Reporting Studio。我想要做的是显示一个日期范围内的项目计数。我将显示所选年份和前两年的计数。但是有第四个计数显示为空白年份。现在我开始认为这是因为时间附在日期上。因此,当最大日期值为 2013 年 3 月 1 日上午 12:00:00 时,则 2013 年 3 月 1 日上午 6:17:00 超出该范围。我需要从日期中删除时间。这是我目前正在使用的:

Case

when [GCR_RECEIVED_DT] between cast(substring ([FromDate],1,10),date) 
and _add_years(cast(substring ([ToDate],1,10),date),-2) 
then extract(year, _add_years([ToDate],-2) )

when [GCR_RECEIVED_DT] between _add_years(cast(substring ([FromDate],1,10),date),1)
and _add_years(cast(substring ([ToDate],1,10),date),-1) 
then extract(year,_add_years([ToDate],-1))

when [GCR_RECEIVED_DT] between _add_years(cast(substring ([FromDate],1,10),date),2)
and cast(substring ([ToDate],1,10),date) 
then extract(year,[ToDate])

end

有人告诉我应该使用强制转换和子字符串。但我不断收到此错误:

执行操作“sqlPrepareWithOptions”状态=“-9”时出错。

伴随着这个重要信息。我确信我不必包括所有这些,但我会这样做。

UDA-SQL-0107 在“准备”操作期间发生一般异常。ORA-00904:“SUBSTRING”:无效标识符 RSV-SRV-0042 追溯:RSReportService.cpp(722):QFException:CCL_CAUGHT:RSReportService::process ()RSReportServiceMethod.cpp(263): QFException: CCL_RETHROW: RSReportServiceMethod::process(): asynchWait_RequestRSASyncExecutionThread.cpp(808): QFException: RSASyncExecutionThread::checkExceptionRSASyncExecutionThread.cpp(260): QFException: CCL_CAUGHT: RSASyncExecutionThread::runImpl(): promptPagingForward_RequestRSASyncExecutionThread.cpp(864): QFException: CCL_RETHROW: RSASyncExecutionThread::processCommand(): promptPagingForward_RequestExecution/RSRenderExecution.cpp(670): QFException: CCL_RETHROW: RSRenderExecution::executeAssembly/RSDocAssemblyDispatch.cpp(291): QFException:CCL_RETHROW: RSDocAssemblyDispatch::dispatchAssemblyAssembly/RSLayoutAssembly.cpp(79): QFException: CCL_RETHROW: RSLayoutAssembly::assembleAssembly/RSDocAssemblyDispatch.cpp(358): QFException: CCL_RETHROW: RSDocAssemblyDispatch::dispatchChildrenAssemblyForwardAssembly/RSReportPagesAssembly.cpp(179): QFException: CCL_RETHROW: RSReportPagesAssembly::assembleAssembly/RSDocAssemblyDispatch.cpp(308):QFException:CCL_RETHROW:RSDocAssemblyDispatch::dispatchAssemblyAssembly/RSPageAssembly.cpp(303):QFException:CCL_RETHROW:RSPageAssembly::assembleAssembly/RSDocAssemblyDispatch.cpp_(308):CDocAssembly.cpp_(308):CDocAssembly :dispatchAssemblyAssembly/RSTableRowAssembly.cpp(177): QFException: CCL_RETHROW: RSTableRowAssembly::assembleAssembly/RSDocAssemblyDispatch.cpp(308): QFException: CCL_RETHROW:RSDocAssemblyDispatch::dispatchAssemblyAssembly/RSTableCellAssembly.cpp(137): QFException: CCL_RETHROW: RSTableCellAssembly::assembleAssembly/RSDocAssemblyDispatch.cpp(358): QFException: CCL_RETHROW: RSDocAssemblyDispatch::dispatchChildrenAssemblyForwardAssembly/RSTableAssembly.cpp(119): QFException: CCL_RETHROW: RSTableAssembly: :assembleAssembly/RSDocAssemblyDispatch.cpp(358): QFException: CCL_RETHROW: RSDocAssemblyDispatch::dispatchChildrenAssemblyForwardAssembly/RSTableRowAssembly.cpp(177): QFException: CCL_RETHROW: RSTableRowAssembly::assembleAssembly/RSDocAssemblyDispatch.cpp(308): QFException: CCL_RETHROW: RSDocAssemblyDispatch::dispatchAssemblyAssembly /RSTableCellAssembly.cpp(137): QFException: CCL_RETHROW: RSTableCellAssembly::assembleAssembly/RSDocAssemblyDispatch.cpp(358): QFException: CCL_RETHROW:RSDocAssemblyDispatch::dispatchChildrenAssemblyForwardAssembly/RSDocAssemblyDispatch.cpp(308): QFException: CCL_RETHROW: RSDocAssemblyDispatch::dispatchAssemblyRSQueryMgr.cpp(1131): QFException: CCL_RETHROW: RSQueryMgr::getResultSetIteratorRSQueryMgr.cpp(1295): QFException: CCL_RETHROW: RSQueryMgr::createIteratorRSQueryMgr.cpp (1569): QFException: CCL_RETHROW: RSQueryMgr::executeRsapiCommandRSQueryMgr.cpp(1559): QFException: CCL_RETHROW: RSQueryMgr::executeRsapiCommandRSQueryMgrExecutionHandlerImpl.cpp(168): QFException: CCL_RETHROW: RSQueryMgrExecutionHandlerImpl::execute()RSQueryMgrExecutionHandlerImpl.cpp(160)QFException : CCL_RETHROW: RSQueryMgrExecutionHandlerImpl::execute()QFSSession.cpp(1147): QFException: CCL_RETHROW: QFSSession::ProcessDoRequest()QFSSession.cpp(1145): QFException: CCL_CAUGHT: QFSSession::ProcessDoRequest()QFSSession.cpp(1102): QFException: CCL_RETHROW: QFSSession::ProcessDoRequest()QFSSession.cpp(1078): QFException: CCL_RETHROW: QFSSession::ProcessDoRequest()QFSConnection.cpp(788): QFException: CCL_RETHROW: QFSConnection: :ExecuteQFSQuery.cpp(213): QFException: CCL_RETHROW: QFSQuery::Execute v2CoordinationQFSQuery.cpp(4456): QFException: CCL_THROW: CoordinationPlanner

我也尝试过 to_date 而不是演员。但我仍然得到同样的东西。有什么帮助吗?

4

1 回答 1

0

我刚刚在我的 ToDate 中使用了 _add_days,所以现在最大日期是 2013 年 3 月 2 日上午 12:00:00。这使得 cognos 可以正确计算 2013 年 3 月 1 日的日期。

于 2013-10-02T14:52:45.677 回答