Home » SQL & PL/SQL » SQL & PL/SQL » ORA-01861: literal does not match format string (Oracle 11g)
ORA-01861: literal does not match format string [message #616683] Thu, 19 June 2014 12:38 Go to next message
theladyd
Messages: 13
Registered: September 2008
Junior Member
I'm trying to update a date column in my table
DMS_BIRTH_DT2 is a subset of DMS_BIRTH_DT with the same formats.
Would someone tell me why the query works on DMS_BIRTH_DT2 and not DMS_BIRTH_DT?

UPDATE BIRTH_DT_TEST2
SET DMS_BIRTH_DT = to_date(substr(to_char(DMS_BIRTH_DT,'mmddyyyy'),1,4)||2099 , 'mm/dd/yyyy HH:MI:SS AM')

20 rows updated


UPDATE BIRTH_DT_TEST
SET DMS_BIRTH_DT = to_date(substr(to_char(DMS_BIRTH_DT,'mmddyyyy'),1,4)||2099 , 'mm/dd/yyyy HH:MI:SS AM')

ORA-01861: literal does not match format string
Re: ORA-01861: literal does not match format string [message #616686 is a reply to message #616683] Thu, 19 June 2014 12:46 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
06192099 would the your string for today. It doesn't match your mask.
You seem to have made a really complicated formula, mixing character string and numbers. i'm surprised the first one worked.
You should not be appending a string to a number. they are different datatypes.

Look at this:
select to_char(sysdate,'mmdd') || '2099' from dual;

[Updated on: Thu, 19 June 2014 12:50]

Report message to a moderator

Re: ORA-01861: literal does not match format string [message #616687 is a reply to message #616683] Thu, 19 June 2014 12:46 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
post results from both statements below

DESC BIRTH_DT_TEST
DESC BIRTH_DT_TEST2
Re: ORA-01861: literal does not match format string [message #616693 is a reply to message #616687] Thu, 19 June 2014 13:17 Go to previous messageGo to next message
theladyd
Messages: 13
Registered: September 2008
Junior Member
DMS_BIRTH_DT2


20 rows updated

DMS_EMPLOYEE_NBR DMS_BIRTH_DT
196651 11/10/2099
937578 06/27/2099
205491 02/06/2099



DMS_BIRTH_DT



[Error] Execution (2: 74): ORA-01861: literal does not match format string
Re: ORA-01861: literal does not match format string [message #616694 is a reply to message #616693] Thu, 19 June 2014 13:21 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and please read http://www.orafaq.com/forum/t/174502/102589/
Previous Topic: ORA-01003: no statement parsed
Next Topic: SQL or loops
Goto Forum:
  


Current Time: Fri Apr 26 14:42:28 CDT 2024