我想在oracle的存储过程中获得系统当前时间的毫秒值例如
2010-12-30 11:07:07的毫秒值为1293678427000在存储过程中该怎么写?可以不用精确到毫秒,到秒就行感谢

解决方案 »

  1.   

    select   to_char(sysdate, 'sssss ')   from   dual
      

  2.   

    SQL> select systimestamp,to_char(systimestamp,'FF')  from dual;
     
    SYSTIMESTAMP                                                                     TO_CHAR(SYSTIMESTAMP,'FF')
    -------------------------------------------------------------------------------- --------------------------
    30-12月-10 11.20.18.656000 上午 +08:00                                           656000
     
    SQL> 
      

  3.   

    SQL> select systimestamp,to_char(systimestamp,'FF1')  from dual;
     
    SYSTIMESTAMP                                                                     TO_CHAR(SYSTIMESTAMP,'FF1')
    -------------------------------------------------------------------------------- ---------------------------
    30-12月-10 11.24.48.671000 上午 +08:00                                           6
     
      

  4.   

    to_number下
    SQL> select systimestamp,to_number('0.'||to_char(systimestamp,'FF9'))  from dual;
     
    SYSTIMESTAMP                                                                     TO_NUMBER('0.'||TO_CHAR(SYSTIM
    -------------------------------------------------------------------------------- ------------------------------
    30-12月-10 11.36.39.265000 上午 +08:00                                                                    0.265
     
    SQL> 
      

  5.   

    不理解楼主 需求 
    select dbms_utility.get_time from dual;
    可否
      

  6.   

    This function determines the current time in 100th's of a second. This subprogram is primarily used for determining elapsed time. The subprogram is called twice – at the beginning and end of some process – and then the first (earlier) number is subtracted from the second (later) number to determine the time elapsed.
      

  7.   

    其实因为数据库里记录的都是毫秒时间,所以我也想直接得到相同类型方便比较dbms_utility.get_time 这个我试过,但如何转成类似于1293678427000的值呢?一般都是在效能测试时用到dbms_utility.get_time
      

  8.   

    晕,这都要什么存储过程啊,一句话就可以搞定啊:SQL> select trunc(86400*(sysdate - to_date('19700101', 'yyyymmdd'))) seconds from dual;   SECONDS
    ----------
    1293713186SQL> select trunc(86400*(to_date('20101230 11:07:07', 'yyyymmdd hh24:mi:ss') - to_date('19700101', 'yyyymmdd'))) seconds from dual;   SECONDS
    ----------
    1293707227
      

  9.   

    select sysdate from dual不行吗
    或者to_char(sysdate)=''