日期:2014-05-16  浏览次数:20347 次

oracle 日期和字符转换函数使用
介绍下oracle中:日期和字符转换函数用法(to_date,to_char)
看了下面的例子知道作用了。很好用!


SQL> select hiredate from emp;

HIREDATE
-----------
1980/12/17
1981/2/20
1981/2/22
1981/4/2
1981/9/28
1981/5/1
1981/6/9
1987/4/19
1981/11/17
1981/9/8
1987/5/23
1981/12/3
1981/12/3
1982/1/23
1981/4/2
1981/12/2
....................................................................
SQL> select hiredate,to_char(hiredate,'yyyy/mm/dd hh24:mi:ss') from emp
  2   where hiredate  >=to_date('19810417','yyyymmdd');

HIREDATE    TO_CHAR(HIREDATE,'YYYY/MM/DDHH
----------- ------------------------------
1981/9/28   1981/09/28 00:00:00
1981/5/1    1981/05/01 00:00:00
1981/6/9    1981/06/09 00:00:00
1987/4/19   1987/04/19 00:00:00
1981/11/17  1981/11/17 00:00:00
1981/9/8    1981/09/08 00:00:00
1987/5/23   1987/05/23 00:00:00
1981/12/3   1981/12/03 00:00:00
1981/12/3   1981/12/03 00:00:00
1982/1/23   1982/01/23 00:00:00
1981/12/2   1981/12/02 00:00:00