Share |

ORA-01861: Literal does not match format string

You tried to convert a literal using a format string, but the length of the format mask didn't match the length of the literal.
eg:
SELECT to_date('20061025','fxyyyy/mm/dd')
FROM dual

SELECT to_date('20061025','fxyyyy/mm/dd')
*
ERROR at line 1:
ORA-01861: literal does not match format string
It can happen sometimes that you are expecting this error, but you still get a correct date.
eg.:
SELECT to_date('20061025','yyyy/mm/dd')
FROM dual
SQL> /

TO_DATE('
---------
25-OCT-06
Succeeds, but following results in an error, because there are no 13 months
SELECT to_date('20061325','yyyy/mm/dd')
FROM dual
SQL> /
SELECT to_date('20061325','yyyy/mm/dd')
*
ERROR at line 1:
ORA-01861: literal does not match format string
This is standard Oracle behaviour (string to date conversion rules).

Oracle tries to convert the month part of a literal to a valid month before applying the format mask.

If you do not want this behaviour, use the FX formatting.

As a general rule of thumb, when using the to_date, to_timestamp, ... functions make sure the literal size matches the format mask
 Was this information helpful?  Yes No
If it was not helpful, please take some time to explain why. This is not to ask questions, you can do so in the forum.

Welcome to our forum for Oracle error: ORA-01861 Add your own message



when i try to insert same values in sql it is getting inserted. But, when i insert through front end (ASP.NET), i am gettting "ORA-01861: literal does not match format string " error.
what would be the problem.
please help as soon as possible.
 
select DISTINCT d.VENDOR_NAME,b.INVOICE_ID,a.ATTRIBUTE1,b.INVOICE_AMOUNT,b.INVOICE_NUM,
a.INVOICE_DATE,abs(a.INVOICE_AMOUNT),
f.TAX_NAME,f.SECTION_CODE,f.TAX_RATE,f.TAX_ID,a.ORG_ID,e.TDS_VENDOR_TYPE_LOOKUP_CODE,e.PAN_NO
from
ap_invoices_all a,ap_invoices_all b,JA_IN_TAX_CODES f,ap_invoice_distributions_all c,
po_vendors d,ja_in_vendor_tds_info_hdr e,hr_operating_units g
where
to_number(a.ATTRIBUTE1)=b.INVOICE_ID
and to_number(c.ATTRIBUTE1)=f.TAX_ID
and b.INVOICE_ID=c.INVOICE_ID
and c.INVOICE_ID=to_number(a.ATTRIBUTE1)
and a.VENDOR_ID=d.VENDOR_ID
and b.VENDOR_ID=d.VENDOR_ID
and a.ATTRIBUTE1where to_number ( a.ATTRIBUTE1 ) = b.INVOICE_ID and to_number ( c.ATTRIBUTE1 ) = f.TAX_ID and b.INVOICE_ID = c.INVOICE_ID and c.INVOICE_ID = to_number ( a.ATTRIBUTE1 ) and a.VENDOR_ID = d.VENDOR_ID and b.VENDOR_ID = d.VENDOR_ID and a.ATTRIBUTE1 is not null
--a.ORG_ID=e.ORGANIZATION_ID and
and g.ORGANIZATION_ID =:Name
--and to_char(a.INVOICE_DATE,'DD-MON-RRRR')
and to_date(a.INVOICE_DATE,'DD-MON-RRRR')
between to_date(:From_date ,'DD-MON-RRRR')and to_date(:To_date,'DD-MON-RRRR')
and d.VENDOR_ID=e.VENDOR_ID
and f.Section_code like :SectionCode
and e.TDS_VENDOR_TYPE_LOOKUP_CODE Like :Vendor_Type
and a.SOURCE like 'TDS'
and a.INVOICE_TYPE_LOOKUP_CODE like 'CREDIT'


when m runing in toad i am not getting any kind of error.
but m registering with the oracle then m running it,it is throwing me a error..
please help me out with this problem..
thanks & regards

Sunil
Are toad and the other program using a different Oracle_home?

It is possible that there is a different value for the NLS_DATE_FORMAT set in the different Oracle home's.

What is the format of the :from_date and :to_date you are passing to the procedure?

It can help to set the nls_date_format to the correct setting at connect time:
alter session set nls_date_format='DD-MON-YYYY'
 
when i m runing in toad i am not getting any kind of error.

But when i am executing through the ASP page it is showing me this error. I tried changing the datefromat but same error i am facing .. could anyone solve this issue or tell me the solution.

I am attaching the query:


SELECT dlvdt, brcode, COUNT (dlvcnno) totaldlv_cnt,
COUNT (pod_cnno) podcnno_cnt,
(COUNT (dlvcnno) - COUNT (pod_cnno)) notpodmf_cnt, COUNT (day0) day0,
COUNT (day2) day2, COUNT (day3) day3, COUNT (day4) day4,
COUNT (day_more4) day_more4
FROM (SELECT cnno dlvcnno, pidmfd_podno pod_cnno, brcode,
TO_CHAR (pidmfd_date, 'DD-MM-YY') podmfdt, dlvdt,
CASE
WHEN ( TO_DATE (pidmfd_date, 'DD-MM-YY')
- TO_DATE (dlvdt, 'DD-MM-YY')
) = 0
THEN '1'
END day0,
CASE
WHEN ( TO_DATE (pidmfd_date, 'DD-MM-YY')
- TO_DATE (dlvdt, 'DD-MM-YY')
) = 1
THEN '1'
END day2,
CASE
WHEN ( TO_DATE (pidmfd_date, 'DD-MM-YY')
- TO_DATE (dlvdt, 'DD-MM-YY')
) = 2
THEN '1'
END day3,
CASE
WHEN ( TO_DATE (pidmfd_date, 'DD-MM-YY')
- TO_DATE (dlvdt, 'DD-MM-YY')
) = 3
THEN '1'
END day4,
CASE
WHEN ( TO_DATE (pidmfd_date, 'DD-MM-YY')
- TO_DATE (dlvdt, 'DD-MM-YY')
) > 3
THEN '1'
END day_more4
FROM (SELECT fdmd_cnno cnno, fdmd_bocode brcode,
TO_CHAR (fdmd_date, 'DD-MM-YYYY') dlvdt
FROM fdm_dtl
WHERE fdmd_bocode IN ('B16', 'B07', 'B11')
AND ( (fdmd_cnno LIKE 'D%')
OR (fdmd_cnno LIKE 'V%')
OR (fdmd_cnno LIKE 'N%')
OR (fdmd_cnno LIKE 'F%')
OR (fdmd_cnno LIKE 'W%')
)
AND fdmd_date BETWEEN TO_DATE ('02-06-2009',
'DD-MM-YYYY')
AND TO_DATE ('04-06-2009',
'DD-MM-YYYY')
AND fdmd_del_status = 'D'
UNION ALL
SELECT drsd_cnno cnno, drsd_brcode brcode,
TO_CHAR (drsd_date, 'DD-MM-YYYY') dlvdt
FROM drs_dtl
WHERE drsd_brcode IN ('B16', 'B07', 'B11')
AND ( (drsd_cnno LIKE 'D%')
OR (drsd_cnno LIKE 'V%')
OR (drsd_cnno LIKE 'N%')
OR (drsd_cnno LIKE 'F%')
OR (drsd_cnno LIKE 'W%')
)
AND drsd_date BETWEEN TO_DATE ('02-06-2009',
'DD-MM-YYYY')
AND TO_DATE ('04-06-2009',
'DD-MM-YYYY')
AND drsd_del_status = 'D') a,
pod_delmf_dtl
WHERE cnno = pidmfd_podno(+) AND brcode = pidmfd_disp_brcode(+))
GROUP BY dlvdt, brcode
ORDER BY brcode, dlvdt

Please note it is running fine in toad but not running through asp

Thanks In Advance


You need to check the format of the char columns containing dates (pidmfd_date, drsd_date,...)
Check if they have the same format as the format you are converting to.

Toad typically only fetches the first x (eg. 50) records, which might not contain a problem.
If your asp page fetches all the records at once, it might be possible that you encounter a problem, even you didn't notive it in toad in the first page.

To check in toad, scroll down your record set until the last error.
 
Hi every body,

Whoever is facing such probelm can play around with the following code below it works.. My problem is solved when coverting the date in the format below. first converting to character and then to date.

TO_DATE (TO_CHAR (pidmfd_date, 'DD-MM-YY'),'DD-MM-YY')

enjoy
 

*****this is pl sql code where empname is shown for those employees who have joined after "hiredate"   *****************

***under is my code for procedure123****
 create or replace procedure procedure123
 (vdate date)
 is
 cursor ecur is select * from emp where to_char(hiredate,'dd month,yyyy')>vdate;

--emp is employee table,

--desc emp gives

/*

 Name                                                                                                              Null?    Type
 ----------------------------------------------------------------------------------------------------------------- -------- ------------------------------------------
 EMPNO                                                                                                             NOT NULL NUMBER(4)
 ENAME                                                                                                                      VARCHAR2(10)
 JOB                                                                                                                        VARCHAR2(9)
 MGR                                                                                    

If you want to supply the TH part of a day, you will need to change your date format to 'DDTH MONTH, YYYY'

 

ORA-01861: Literal does not match format string

This error is displayed when logging in to Windows XP as a limited user.. Not under su or administrator. So somehow the XP user does not have correct permissions to run the GUI.

However the administrator level login under XP works correctly. The GUI on XP connects to Oracle on a RHE server. The GUI is a company developed program used to manipulate parking spaces.

Can it be that both users have different local settings on XP?

For example the admin user have date format mm/dd/yyyy while the non-privileged user have dd/mm/yyyy.

Maybe the GUI tries to take this setting into account, but for some reason fails to use the format correctly?

 

DbMotive - Thanks for the response.. I can display the admin settings, but when logged in as a limited user, am unable to see anything but the basic date/time. They appear to be the same, when checked via Control Panel/Regional & Language Options. I think this has to be a permissions setting, but unable to see where.  

"Can it be that both users have different local settings on XP? For example the admin user have date format mm/dd/yyyy while the non-privileged user have dd/mm/yyyy.  Maybe the GUI tries to take this setting into account, but for some reason fails to use the format correctly?"

One other thing to check is the value for NLS_DATE_FORMAT.

This can either be entered before starting the GUI (thus you start using a batch script), or specified as an environment variable (Window key + pause/break, advanced tab, environment variables; check both user variables and system variables).

It might also be specified at HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE (in one of the subtrees).

If it is set, your non-admin account probably doesn't have access to it

Hi DbMotive,

Thanks for your input.. It eventually put me on the right track. I had looked at the Oracle date/time settings in the reg, but not at the entry for my companies software. In the entry "HKEY_CURRENT_USER\Software\Interplanet\XYZ\XYZ.SchedulerProperties" the date format was the reverse of the Oracle reg settings. Both the Ora date str and format were wrong. I manually changed these. Works perfectly now!! Appreciate your time. Brgds, 

 

How to resolve this error.

i'm getting error when executed DATE. where to specify format????

You can specify a different date format by setting the NLS_DATE string

You can also use a different date format using the to_date function.

eg: select to_date('01-JAN-2010', 'DD-MON-YYYY') from dual;

 

hi i have this number 1273769263113 for a varchar field in my table, i need to convert it into date, can any one help please

What should be the date format? Is it a Julian date, seconds since a certain date, ...

If it is seconds since 01/01/1970 you can use:

SELECT

CAST(FROM_TZ(TO_timestamp ('19700101000000', 'YYYYMMDDHH24MISS') +    NUMTODSINTERVAL

(1273769263113 / 1000 ,'SECOND'), 'GMT')

AT TIME ZONE sessiontimezone

AS timestamp ) "the_date"

FROM dual

 


Add your message

 Please provide your personal info 



 Please ask your message as briefly and clear as possible 

 Spam Protection 
Validation Code: z5bgyujsrus2qhmic


Ask Your Question

If you need more information about this particular error message, you can leave a forum message.

We are replying to this message whenever we have some spare time, so please do not consider this as a private 'solve my critical issue asap' service.

Should you need professional Oracle Assistance to make your project a success, please have a look at our consultancy services.


Spam Protection

In order to prevent automatic generation of messages, we are asking for a validation code. This code is unique and is generated every time a new message is asked.

If you do not enter the validation correctly, your message will not be recorded.


Forum Rules

Please be polite, do not USE ALL UPPERCASE, no insults, violance or any other threats.