SQL Developer is returning only the date, not the time. How do I fix this?

后端 未结 7 976
粉色の甜心
粉色の甜心 2020-12-22 16:08

Here\'s what SQL Develoepr is giving me, both in the results window and when I export:

CREATION_TIME       
------------------- 
27-SEP-12
27-SEP-12
27-SEP-1         


        
相关标签:
7条回答
  • 2020-12-22 16:53

    Well I found this way :

    Oracle SQL Developer (Left top icon) > Preferences > Database > NLS and set the Date Format as MM/DD/YYYY HH24:MI:SS

    0 讨论(0)
  • 2020-12-22 16:57

    To expand on some of the previous answers, I found that Oracle DATE objects behave different from Oracle TIMESTAMP objects. In particular, if you set your NLS_DATE_FORMAT to include fractional seconds, the entire time portion is omitted.

    • Format "YYYY-MM-DD HH24:MI:SS" works as expected, for DATE and TIMESTAMP
    • Format "YYYY-MM-DD HH24:MI:SSXFF" displays just the date portion for DATE, works as expected for TIMESTAMP

    My personal preference is to set DATE to "YYYY-MM-DD HH24:MI:SS", and to set TIMESTAMP to "YYYY-MM-DD HH24:MI:SSXFF".

    0 讨论(0)
  • 2020-12-22 16:57

    This will get you the hours, minutes and second. hey presto.

    select
      to_char(CREATION_TIME,'RRRR') year, 
      to_char(CREATION_TIME,'MM') MONTH, 
      to_char(CREATION_TIME,'DD') DAY, 
      to_char(CREATION_TIME,'HH:MM:SS') TIME,
      sum(bytes) Bytes 
    from 
      v$datafile 
    group by 
      to_char(CREATION_TIME,'RRRR'), 
      to_char(CREATION_TIME,'MM'), 
      to_char(CREATION_TIME,'DD'), 
      to_char(CREATION_TIME,'HH:MM:SS') 
     ORDER BY 1, 2; 
    
    0 讨论(0)
  • 2020-12-22 17:05

    Date format can also be set by using below query :-

    alter SESSION set NLS_DATE_FORMAT = 'date_format'

    e.g. : alter SESSION set NLS_DATE_FORMAT = 'DD-MM-YYYY HH24:MI:SS'

    0 讨论(0)
  • 2020-12-22 17:06

    Neither of these answers would work for me, not the Preferences NLS configuration option or the ALTER statement. This was the only approach that worked in my case:

    dbms_session.set_nls('nls_date_format','''DD-MM-YYYY HH24:MI:SS''');
    

    *added after the BEGIN statement

    I am using PL/SQL Developer v9.03.1641

    Hopefully this is of help to someone!

    0 讨论(0)
  • 2020-12-22 17:10

    Can you try this?

    Go to Tools> Preferences > Database > NLS and set the Date Format as MM/DD/YYYY HH24:MI:SS

    0 讨论(0)
提交回复
热议问题