Basit
Basit

Reputation: 8606

Getting error while subtracting two dates(inconsistent datatypes: expected char got date)

I have a query in which I am subtracting two dates but I am getting error. Here is the query

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’} 

But I am getting error that

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

What i am doing wrong?

Upvotes: 0

Views: 2315

Answers (1)

Nick Krasnov
Nick Krasnov

Reputation: 27251

The :endDate bind variable is the cause of the error. Try to explicitly convert :endDate value to a value of date datatype using to_date function. For example:

 ....

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

 ....

Upvotes: 1

Related Questions