且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Oracle和.NET的TimeZone时间/日期格式

更新时间:2023-11-29 14:39:04

Oracle DATE具有日期和时间部分,但没有时区. TIMESTAMP WITH [LOCAL] TIME ZONE将具有时区,并且还将具有亚秒级的精度.

An Oracle DATE has a day and a time component but no time zone. A TIMESTAMP WITH [LOCAL] TIME ZONE will have a time zone and will also have sub-second precision.

您可以通过几种不同的方式更改将DATE数据转换为字符串以进行显示的方式.首先,它使用显式的TO_CHAR

You can change how the DATE data is converted into a string for display in a few different ways. First, it to use an explicit TO_CHAR

SELECT to_char( <<your_date_column>>, 'YYYY-MM-DD HH24:MI:SS' )
  FROM your_table

第二,您可以更改会话的NLS_DATE_FORMAT,以便会话始终以特定格式显示数据

Second, you can change the NLS_DATE_FORMAT of your session so that the session always displays data in a particular format

ALTER SESSION SET nls_date_format = 'yyyy-mm-dd hh24:mi:ss';
SELECT <<your_date_column>>
  FROM your_table

第三,在SQL Developer中,您可以更改其用于显示DATE数据的字符串格式.如果转到Tools | Preferences | Database | NLS,将出现一个Date Format字段.如果将其从DD-MON-RR更改为YYYY-MM-DD HH24:MI:SS,您将获得默认显示的日期和时间.

Third, in SQL Developer, you can change the string format it uses to display DATE data. If you go to Tools | Preferences | Database | NLS, there will be a Date Format field. If you change that from DD-MON-RR to YYYY-MM-DD HH24:MI:SS, you'll get the day and the time displayed by default.