select to_date('2004-01-01 12:00:00','yyyy-mm-dd hh24:mi:ss')
from dual;

解决方案 »

  1.   

    select to_date('2003'||'-09-08','yyyy-mm-dd') from dual
      

  2.   

    只转换时间的话会有问题:
    10:23:02 SQL> select sysdate from dual;SYSDATE
    -------------------
    2004-09-15 10:23:22已用时间:  00: 00: 00.32
    10:23:22 SQL> select to_date('10:23','hh24:mi') from dual;TO_DATE('10:23','HH
    -------------------
    2004-09-01 10:23:00已用时间:  00: 00: 00.47
    10:23:59 SQL> 
      

  3.   

    把这个转化为时间相关的类型例如这样select to_date('12:22','hh:mi') from dual的出来的结果是2004-9-1 12:22:00不知道你最后想要的是什么结果,你想要一个真正的日期,还是一个时间间隔值,真正的日期的话必须要有年月日的
      

  4.   

    只要时间。在数据库中有一个字段为CH_HM,为varchar2型,数据格式为hhmm。希望能够转成hh:mm的时间(日期)型,不需要年月日信息。
      

  5.   

    补充一下,如果说计这个小时是为了跟其他的时间相加,那么可以参考下面的格式
    select sysdate + TO_DSINTERVAL('0 00:00:00') from dual结果:2004-9-15 10:38:18select sysdate + TO_DSINTERVAL('0 01:00:00') from dual结果:2004-9-15 11:38:34第一个0代表天数,后面的就是小时,分,秒,我试了必须按照这种格式
      

  6.   

    oracle里没有这样的日期型说法,你具体想用在什么地方???为什么要这样应用?
      

  7.   

    先用to_date(),然后用to_char()select to_char(to_date('2004-01-01'||'12:23:00','yyyy-mm-dd hh24:mi:ss'),'hh24:mi') from dualTO_CH
    -----
    12:23已选择 1 行。
      

  8.   

    这样的话你使用的时候需要先进行还原了
    select to_char(datecole,'hh24:mi') from yourtable;
      

  9.   

    是Smalltalk/VisualWorks上的一个应用。
      

  10.   

    找这个方法解决了如你urColumn里值是1234
    to_date(substr(urColumn,1,2) || ':' || substr(urColumn,3,2),'HH24:MI')
    就变成时间格式12:34了如果各位还有更好的方法,希望提出,三天以内结帖,分会加到100的。
      

  11.   

    11:28:41 SQL> Select to_date(substr('1234',1,2)||':'||substr('1234',3,4),'hh24:mi') As sj From dual;
    SJ
    ----------
    01-9月 -0411:28:42 SQL> SELECT SUBSTR('1234',1,2)||':'||SUBSTR('1234',3,4) SJ
    11:29:11   2    FROM DUAL;SJ
    -----
    12:3411:29:16 SQL>