ERROR ORA-00932: inconsistent datatypes: expected DATE got NUMBER

user3845574 picture user3845574 · Sep 15, 2014 · Viewed 11.1k times · Source

I am trying to execute the following sql statement for an oracle database:

UPDATE PARENT
SET RENEW_DATE = TO_DATE('08/31/' + EXTRACT(YEAR FROM JOINED), 'MM/dd/yyyy')
WHERE STATUS_IND = 'Active';

I am expecting to get the year piece from the field called Joined which is a date formatted like MM/dd/yyyy. I want the end result, or the value I am setting to look like '8/31/2015' for example.

Any help is appreciated I have tried multiple things.

Answer

Chris Barlow picture Chris Barlow · Sep 15, 2014

Use a || instead of the + sign to concatinate the date together.

UPDATE PARENT 
  SET RENEW_DATE = TO_DATE('08/31/' || EXTRACT(YEAR FROM JOINED), 'MM/dd/yyyy') 
WHERE STATUS_IND = 'Active'