Conversion method: 1. Use the to_char() function to output the time and date in the specified format. The result is a string, the syntax is "to_char(date,"conversion format")"; 2. Use to_date () function, syntax "to_date("time string","converted time and date format")".
The operating environment of this tutorial: Windows 7 system, Oracle 11g version, Dell G3 computer.
oracle time and date conversion into timestamp
In Oracle, there are two methods to convert time and date into timestamp:
to_char() function
to_date() function
##1. to_char()
Output the time and date in the specified format, and the result is a string, not a date type.to_char(日期,"转换格式" )
select to_char(sysdate, 'yyyy-mm-dd') from dual; select to_char(sysdate, 'yyyy/mm/dd') from dual; select to_char(sysdate, 'yyyymmdd') from dual; select to_char(sysdate, 'yyyymmdd hh24:mi:ss') from dual;
select to_char(sysdate,'yyyy') from dual; select to_char(sysdate,'mm') from dual; select to_char(sysdate,'hh24') from dual; select to_char(sysdate,'mi') from dual;
2, to_date()
Convert the string to the specified time and date formatto_date("时间字符串","转换的时间日期格式")
select to_date('20220103','yyyymmdd') from dual; select to_date('20220103','yyyy-mm-dd') from dual; select to_date('20220103','yyyy/mm/dd') from dual; select to_date('20220103','yyyy-mm-dd hh24:mi:ss') from dual;
Oracle Tutorial"
The above is the detailed content of How to convert time date into timestamp in oracle. For more information, please follow other related articles on the PHP Chinese website!