Oracle's default date format is YYYY-MM-DD, WHY?

后端 未结 12 2499
温柔的废话
温柔的废话 2020-11-29 00:44

Oracle\'s default date format is YYYY-MM-DD. Which means if I do:

 select some_date from some_table

...I lose the time portion of

12条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 01:02

    To answer to your question that is WHY default date don't display TIME part, the only answer I find is

    Oracle teams are composed of LAZY developpers or responsibles :-)

    Why ?

    Because DATE, TIME and DATETIME datatypes exist in SQL and Oracle has not yet implemented it !!!

    It is a shame for Oracle.

    But the correct answer to your problem is not to define a FIX default format but a SIGNIFICANT default format that display only significant digits so that DATE, TIME or DATETIME values displayed (by default) contains always all important digits.

    Example:

    2015-10-14          will be displayed as 2015-10-14 (or default DATE format)
    2018-10-25 12:20:00 will be displayed as 2018-10-25 12:20
    1994-04-16 16       will be displayed as 1994-04-16 16
    

    The principle is simple.

    All digits being part of DATE will always be displayed as INTEGER part of float number. For TIME part, only significant part will be displayed as for DECIMAL part in float number. Naturally, for TIME type (only HH:MM:SS), the DATE part is never displayed.

提交回复
热议问题