在减去两个日期时获取错误(不一致的数据类型:预期的char获取日期)

时间:2012-11-30 06:22:01

标签: sql oracle oracle11g

我有一个查询,其中我减去两个日期,但我收到错误。这是查询

select LOSA_APP.app_ref_no AS "App.Ref.No.", 
       CODE_BRANCH.branch_name AS "Business Unit",
       ...,
       :endDate - LOSA_APP_Z.li_dt AS "Day Count",.
       ...
 from losa_app LOSA_APP
INNER JOIN code_branch CODE_BRANCH
   ON LOSA_APP.attend_branch = CODE_BRANCH.branch_id
....
where LOSA_APP.app_status='A'; -- Application Status in {‘accepted’} 

但我收到错误

ORA-00932: inconsistent datatypes: expected CHAR got DATE
00932. 00000 -  "inconsistent datatypes: expected %s got %s"
*Cause:    

我做错了什么?

1 个答案:

答案 0 :(得分:1)

:endDate绑定变量是导致错误的原因。尝试使用:endDate函数将to_date值显式转换为date数据类型的值。例如:

 ....

 to_date(:endDate, 'dd.mm.yyyy') - LOSA_APP_Z.li_dt AS "Day Count",

 ....