Home » SQL & PL/SQL » SQL & PL/SQL » ORA-01830: date format picture ends before converting entire input string
ORA-01830: date format picture ends before converting entire input string [message #24258] Tue, 04 February 2003 23:49 Go to next message
Abhay Mukewar
Messages: 1
Registered: February 2003
Junior Member
I have a solris O.S. with ORACLE9i
My Query is as follows :-

SELECT to_char(to_date( 'DateColumnName' ,'dd/mm/yy'),'dd/mm/yyyy'), sum(CAllsReceived) from VMCC_STATISTICS where time_from between to_date('30/01/2003' , 'dd/mm/yyyy') AND (to_date('30/01/2003' , 'dd/mm/yyyy') + 4) group by to_date(time_from , 'dd/mm/yy') order by to_date(time_from , 'dd/mm/yy')

DateColumnName is the name of the column which stores timestamp for ex. 19-NOV-2002 12:01:15

The exception is as follows:-

java.sql.SQLException: ORA-01830: date format picture ends before converting entire input string

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:889)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1681)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1870)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:538)

How ever this query works perfect with ORACLE8I and windows

Thanks in Advance
Re: ORA-01830: date format picture ends before converting entire input string [message #24262 is a reply to message #24258] Wed, 05 February 2003 02:36 Go to previous message
Barbara Boehmer
Messages: 9105
Registered: November 2002
Location: California, USA
Senior Member
The error message is somewhat self-explanatory. However, to re-phrase it, the format that you have used, like 'dd/mm/yyyy' is shorter than your DateColumnName value, like '19-NOV-2002 12:01:15', for which the correct format would be 'DD-MON-YYYY HH24:MI:SS'. Please see the examples below. The first example duplicates the error message received. The second example shows the correct way. I have also included the full code below that. This assumes that your DateColumnName is of VARCHAR2 data type. If it is not VARCHAR2, but is date or timestamp data type, then there is not need to use the TO_DATE function to convert it to a date; you would just use the TO_CHAR function with the output format desired. I have also included an example of that. Also, you shouldn't have quotes around your DateColumnName.

SQL> -- wrong way:
SQL> SELECT TO_DATE ('19-NOV-2002 12:01:15', 'DD-MON-YYYY') FROM DUAL
  2  /
SELECT TO_DATE ('19-NOV-2002 12:01:15', 'DD-MON-YYYY') FROM DUAL
                *
ERROR at line 1:
ORA-01830: date format picture ends before converting entire input string

SQL> 
SQL> 
SQL> -- correct way:
SQL> SELECT TO_DATE ('19-NOV-2002 12:01:15', 'DD-MON-YYYY HH24:MI:SS') FROM DUAL
  2  /

TO_DATE('
---------
19-NOV-02

-- if DateColumnName is VARCHAR2:
SELECT   to_char(to_date( DateColumnName ,'DD-MON-YYYY HH24:MI:SS'),'dd/mm/yyyy'), 
         sum(CAllsReceived) 
from     VMCC_STATISTICS 
where    time_from between to_date('30/01/2003' , 'dd/mm/yyyy') 
                   AND     (to_date('30/01/2003' , 'dd/mm/yyyy') + 4) 
group by to_date(time_from , 'dd/mm/yy') 
order by to_date(time_from , 'dd/mm/yy');

-- if DateColumnName is date or timestamp:
SELECT   to_char(DateColumnName, 'dd/mm/yyyy'), 
         sum(CAllsReceived) 
from     VMCC_STATISTICS 
where    time_from between to_date('30/01/2003' , 'dd/mm/yyyy') 
                   AND     (to_date('30/01/2003' , 'dd/mm/yyyy') + 4) 
group by to_date(time_from , 'dd/mm/yy') 
order by to_date(time_from , 'dd/mm/yy');

Previous Topic: ORA-17008 "Closed Connection "
Next Topic: Function returning Array
Goto Forum:
  


Current Time: Thu May 01 02:09:54 CDT 2025