开发者

Formatting Dates and Times in Oracle

I'm working with O开发者_如何学Cracle 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


try "DD/MM/YYYY HH24:MI"

some blind text to make the answer long enough


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  


Try:

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

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


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 ..
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜