IT咨询服务商业智能日期

已知输入日期求季初日期

已知输入日期参数‘p_date’,时间格式为YYYY-mm-dd现在需要季初日期,然后用between。。。and。。。联接当天日期统计季报数目,在report studio里添加查询项“季初日期”代码如下:case when (substr(?p_date?,6,2) in ('01','02','03') then cast ((cast (substr(?p_date?,1,4...显示全部

已知输入日期参数‘p_date’,时间格式为YYYY-mm-dd

现在需要季初日期,然后用between。。。and。。。联接当天日期统计季报数目,在report studio里添加查询项“季初日期”

代码如下:

case when (substr(?p_date?,6,2) in ('01','02','03') then cast ((cast (substr(?p_date?,1,4 ) as nvarchar(4))||'-01-01') as date))

when (substr(?p_date?,6,2) in ('04','05','06') then cast ((cast (substr(?p_date?,1,4 ) as nvarchar(4))||'-04-01') as date))

when (substr(?p_date?,6,2) in ('07','08','09') then cast ((cast (substr(?p_date?,1,4 ) as nvarchar(4))||'-07-01') as date))

when (substr(?p_date?,6,2) in ('10','11','12') then cast ((cast (substr(?p_date?,1,4 ) as nvarchar(4))||'-10-01') as date))

end

报错如下:

QE-DEF-0459 CCLException

QE-DEF-0260"case when (substr(?p_date?,6,2) in ('01','02','03') then "的位置57之前或者附近存在解析错误

QE-DEF-0261 QFWP - 正在解析文本 :

case when (substr(?p_date?,6,2) in ('01','02','03') then cast ((cast (substr(?p_date?,1,4 ) as nvarchar(4))||'-01-01') as date))

when (substr(?p_date?,6,2) in ('04','05','06') then cast ((cast (substr(?p_date?,1,4 ) as nvarchar(4))||'-04-01') as date))

when (substr(?p_date?,6,2) in ('07','08','09') then cast ((cast (substr(?p_date?,1,4 ) as nvarchar(4))||'-07-01') as date))

when (substr(?p_date?,6,2) in ('10','11','12') then cast ((cast (substr(?p_date?,1,4 ) as nvarchar(4))||'-10-01') as date))

end

求各位大神给个解决方法,快疯掉了

收起
参与7

查看其它 2 个回答迁安大少的回答

迁安大少迁安大少软件开发工程师宇信易诚

这类问题最好在建模过程中进行相关度量的设计,避免在web上进行相对复杂的处理;

软件开发 · 2016-04-13
浏览1155

回答者

迁安大少
软件开发工程师宇信易诚
擅长领域: 大数据cognos联机分析处理

迁安大少 最近回答过的问题

回答状态

  • 发布时间:2016-04-13
  • 关注会员:4 人
  • 回答浏览:1155
  • X社区推广