select to_char(PROD_LENG,'hh24:mi')  from production

解决方案 »

  1.   

    SQL> select to_char(PROD_LENG,'hh24:mi')  from production
      2  ;
    select to_char(PROD_LENG,'hh24:mi')  from production
                   *
    ERROR at line 1:
    ORA-00904: "PROD_LENG": invalid identifier
      

  2.   

    to_date()函数返回的是一个时间点,而不是一个时间段啊;
    prod_leng 你应该用number 表示,然后 换算;
    注意 两个date型数据相减得到的是以天为单位的number型数据!!!!
      

  3.   

    select to_char(PROD_LENGth,'hh24:mi')  from production
      

  4.   

    楼上说的就是我想要的结果
    谢谢
    我查了一下Oracle SQL Reference,但是没有找到to_char(PROD_LENGth,'hh24:mi'),ckc能解释一下那个'th'的作用吗?
      

  5.   

    参考:
    SQL> select to_char(sysdate,'hh24:mi') from dual;TO_CH
    -----
    07:58
      

  6.   

    楼主提供的表里面根本没有prod_leng这个字段所以出现:
    SQL> select to_char(PROD_LENG,'hh24:mi')  from production
      2  ;
    select to_char(PROD_LENG,'hh24:mi')  from production
                   *
    ERROR at line 1:
    ORA-00904: "PROD_LENG": invalid identifier用to_char()对date类型进行转换,可以转换为需要的类型。