2

I'm working with Oracle and I'm using SQL Developer-1.5.4.59.40 but I have a problem. I don't know how use the format for date. I want to use a format: "dd/mm/aaaa hh24:mm" but Oracle doesn't accept it. Tthe error is:

ORA-01830: La máscara de formato de fecha termina antes de convertir toda la cadena de entrada

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
trifolius
  • 51
  • 1
  • 1
  • 6

4 Answers4

1

try "DD/MM/YYYY HH24:MI"

some blind text to make the answer long enough

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
1

to change the date format for all queries (and have it remembered day to day)

in SQL Deverloper:

  1. Goto Tools
  2. Preferences
  3. Database
  4. NLS
  5. and change Date Format to "DD/MM/YYYY HH24:MI" (as suggested by Jens)

now to simply do that in a query

SELECT 
        TO_CHAR(SYSDATE, 'DD/MM/YYYY HH24:MI') 
  FROM DUAL ;

  TO_CHAR(SYSDATE,'DD/MM/YYYYHH24:MI') 
------------------------------------ 
04/01/2011 16:08  
Harrison
  • 8,970
  • 1
  • 32
  • 28
  • uhmm also use jsp for aplication – trifolius Jan 04 '11 at 21:20
  • @user563062, sorry jsp was not mentioned in the original question, you can use parameters to handle the date casting into the package/procedures you are using, a simple google search yields several examples of how to do this: http://www.java2s.com/Code/Java/Database-SQL-JDBC/GetdatefromOracle.htm and http://download.oracle.com/javase/1.4.2/docs/api/java/sql/PreparedStatement.html – Harrison Jan 05 '11 at 13:18
0

Try:

to_date(some_date,'dd/mm/yyyyhh24:mi:ss')

Where some_date is for example '31/08/2012'.

matsjoyce
  • 5,744
  • 6
  • 31
  • 38
juanchoelx
  • 387
  • 1
  • 6
  • 20
0

If some_date is the column name of date type then you can use the to_char function to convert to any format.

select to_char(some_date,'dd/mm/yyyy hh24:mi:ss') from ..
matsjoyce
  • 5,744
  • 6
  • 31
  • 38
Nilesh
  • 2,015
  • 3
  • 19
  • 21