[20111229]date time timestamp? ansi liternals.txt
今天看一篇文章,發現日期可以寫成這樣
date '2011-1-1'
google發現如下連結:
自己測試一下,一般我個人喜歡定義環境變數如下:
$ export | grep NLS
declare -x NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
declare -x NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
declare -x NLS_TIMESTAMP_FORMAT="YYYY-MM-DD HH24:MI:SS.FF"
declare -x NLS_TIMESTAMP_TZ_FORMAT="YYYY-MM-DD HH24:MI:SS.FF"
declare -x NLS_TIME_FORMAT="HH24:MI:SS.FF"
select date '2012-1-2' from dual;
DATE'2012-1-2'
-------------------
2012-01-02 00:00:00
並且如果寫成
SQL> select date '2012/1/2' from dual;
*
ERROR at line 1:
ORA-01861: literal does not match format string
感覺根本不使用/分割.並且date 不能使用時分秒。
SQL> select date '2012-1-2 15:12:39' from dual;
select date '2012-1-2 15:12:39' from dual
*
ERROR at line 1:
ORA-01861: literal does not match format string
還有其他的如time,timestamp.
SQL> select time '12:23:21' ,timestamp '2012-1-1 12:23:34'from dual;
TIME'12:23:21' TIMESTAMP'2012-1-112:23:34'
---------------------- ------------------------------
12:23:21.000000000 2012-01-01 12:23:34.000000000
不允許兩者相加,例子:
SQL> select date '2012-1-1' + time '12:23:21' from dual;
select date '2012-1-1' + time '12:23:21' from dual
*
ERROR at line 1:
ORA-30087: Adding two datetime values is not allowed
可以這樣相加,例子:
SQL> select date '2012-1-2'+ interval '15' hour from dual ;
SQL> select date '2012-1-2'+ to_dsinterval('0 2:0:0') from dual;
SQL> select date '2012-1-2'+ 1/24 + 15/1440 + 40/86400 from dual;
DATE'2012-1-2'+1/24
-------------------
2012-01-02 01:15:40
date '2011-1-1'
google發現如下連結:
自己測試一下,一般我個人喜歡定義環境變數如下:
$ export | grep NLS
declare -x NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
declare -x NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
declare -x NLS_TIMESTAMP_FORMAT="YYYY-MM-DD HH24:MI:SS.FF"
declare -x NLS_TIMESTAMP_TZ_FORMAT="YYYY-MM-DD HH24:MI:SS.FF"
declare -x NLS_TIME_FORMAT="HH24:MI:SS.FF"
select date '2012-1-2' from dual;
DATE'2012-1-2'
-------------------
2012-01-02 00:00:00
並且如果寫成
SQL> select date '2012/1/2' from dual;
*
ERROR at line 1:
ORA-01861: literal does not match format string
感覺根本不使用/分割.並且date 不能使用時分秒。
SQL> select date '2012-1-2 15:12:39' from dual;
select date '2012-1-2 15:12:39' from dual
*
ERROR at line 1:
ORA-01861: literal does not match format string
還有其他的如time,timestamp.
SQL> select time '12:23:21' ,timestamp '2012-1-1 12:23:34'from dual;
TIME'12:23:21' TIMESTAMP'2012-1-112:23:34'
---------------------- ------------------------------
12:23:21.000000000 2012-01-01 12:23:34.000000000
不允許兩者相加,例子:
SQL> select date '2012-1-1' + time '12:23:21' from dual;
select date '2012-1-1' + time '12:23:21' from dual
*
ERROR at line 1:
ORA-30087: Adding two datetime values is not allowed
可以這樣相加,例子:
SQL> select date '2012-1-2'+ interval '15' hour from dual ;
SQL> select date '2012-1-2'+ to_dsinterval('0 2:0:0') from dual;
SQL> select date '2012-1-2'+ 1/24 + 15/1440 + 40/86400 from dual;
DATE'2012-1-2'+1/24
-------------------
2012-01-02 01:15:40
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-714159/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- java convert timestamp to date and timeJava
- [20230207]ANSI DATE and TIMESTAMP SQL syntax.txtSQL
- date、timestamp欄位型別型別
- oracle plsql定義date_timestamp_with time zoneOracleSQL
- mysql資料庫date 、datetime、time、timestamp區別MySql資料庫
- oracle timestamp轉換date及date型別相減Oracle型別
- Mysql日期(DATE, TIME, DATETIME, TIMESTAMP)型別的比較MySql型別
- Oracle中Date和Timestamp的區別Oracle
- 將timestamp轉成date格式的指令碼指令碼
- 面試題:能談談Date、Datetime、Time、Timestamp、year的區別嗎?面試題
- date和timestamp型別之間的轉換型別
- String和Date、Timestamp之間的轉換
- JAVA裡的String、Timestamp、Date相互轉換Java
- 將timestamp型別轉換為date型別型別
- ORACLE DATE型別和TIMESTAMP型別DUMP換算Oracle型別
- oracle資料型別date和timestamp的轉化Oracle資料型別
- Java:String和Date、Timestamp之間的轉換Java
- python date 和 datetime 的取值範圍(對比 Mysql 的 datetime 和 timestamp)PythonMySql
- timestamp with local time zone型別和timestamp with time zone型別
- mysql中的date、datetime、timestamp你還不知道怎麼使用嗎MySql
- Oracle timestamp_to_scn and scn_to_timestampOracle
- ORACLE DATE和TIMESTAMP資料型別的比較(一) (轉)Oracle資料型別
- ORACLE DATE和TIMESTAMP資料型別的比較(二) (轉)Oracle資料型別
- TIMESTAMP和TIMESTAMP WITH TIME ZONE之間的總結
- Oracle TimestampOracle
- 6、TIMESTAMP WITH TIME ZONE和TIMESTAMP WITH LOCAL TIME ZONE的實踐理解
- oracle 中關於當前的sysdate,sysstimestap,current_date,curent_timestamp 區別Oracle
- ORA-00001 : Unique Constraint Violated caused by DATE VS Timestamp(6)AI
- Oracle timestamp型別轉換date格式指令碼(精確到秒)Oracle型別指令碼
- mysql CURRENT_TIMESTAMP 和ON UPDATE CURRENT_TIMESTAMPMySql
- [Warning] TIMESTAMP with implicit DEFAULT --explicit_defaults_for_timestamp
- MySQL: datetime vs timestampMySql
- partitioned by timestamp datatype
- MySQL之timestampMySql
- [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.explicit_defaults_for_timestamp
- oracle中date資料型別與timestamp資料型別的轉換Oracle資料型別
- (轉)PLS_INTEGER型別與timestamp型別、date、及時間函式型別函式
- oracle將表中date資料型別修改為timestamp資料型別Oracle資料型別