Oracle TO_DATE with only time input will add date component based on what logic? -
running code in oracle 11/12:
select to_date('101200', 'hh24miss') dual
will return date component oracle automatically adds based on logic?
eg:
select to_char(to_date('101200', 'hh24miss'), 'yyyymmdd') dual
returns
20160701
we see added date component set first day of current month. logic come from?
thanks in advance
a value of date data type has date , time components. if specify time portion of datetime value did, date portion defaults first day of current month.
here 1 of places (7th paragraph) in oracle documentation behavior documented.
there undocumented time
literal , time
data type (needs enabled via 10407
(datetime time datatype creation) event) if need use , store time, without date part.
here small demonstration of using time
literal , time
data type. again it's undocumented , unsupported feature.
sql> select time '11:32:00' res 2 dual; res ------------------------ 11.32.00.000000000
you can use time literal without enabling 10407
event, in order able define column of time
data type 10407
event needs enabled:
sql> create table time_table(time_col time); create table time_table(time_col time) * error @ line 1: ora-00902: invalid datatype -- enable 10407 event sql> alter session set events '10407 trace name context forever, level 1'; session altered.
now can create table column of time
data type:
sql> create table time_table(time_col time); table created. sql> insert time_table(time_col) 2 values(time '11:34:00'); 1 row created. sql> select * time_table; time_col --------------- 11.34.00 sql> alter session set events '10407 trace name context off'; session altered.
Comments
Post a Comment