Вопрос по sql – Извлечение общего количества секунд из типа данных интервала

27

Error: User Rate Limit ExceededtimestampsError: User Rate Limit ExceededintervalError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

select abs( extract( second from interval_difference ) 
          + extract( minute from interval_difference ) * 60 
          + extract( hour from interval_difference ) * 60 * 60 
          + extract( day from interval_difference ) * 60 * 60 * 24
            )
  from ( select systimestamp - (systimestamp - 1) as interval_difference
           from dual )

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded Gaurav Soni
Error: User Rate Limit Exceeded Gaurav Soni
Error: User Rate Limit Exceeded Blaf

Ваш Ответ

7   ответов
-2

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
4

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

... unlike .NET, Oracle provides no simple equivalent to TimeSpan.TotalSeconds.

Error: User Rate Limit Exceeded

18

Error: User Rate Limit Exceeded

select extract(day from (ts1-ts2)*86400) from dual;

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededextract(day from (ts1-ts2)*86400*1000) / 1000Error: User Rate Limit Exceeded
8

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

SELECT ( (A + 0) - (B + 0) ) * 24 * 60 * 60 
FROM
(
   SELECT SYSTIMESTAMP A,
          SYSTIMESTAMP - INTERVAL '1' MINUTE B
   FROM DUAL
);
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
1

Error: User Rate Limit Exceeded

select (cast(timestamp1 as date)-cast(timestamp2 as date))*24*60*60)
2

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

CREATE OR REPLACE FUNCTION intervalToSeconds( 
     pMinuend TIMESTAMP , pSubtrahend TIMESTAMP ) RETURN NUMBER IS

vDifference INTERVAL DAY TO SECOND ; 

vSeconds NUMBER ;

BEGIN 

vDifference := pMinuend - pSubtrahend ;

SELECT EXTRACT( DAY    FROM vDifference ) * 86400
     + EXTRACT( HOUR   FROM vDifference ) *  3600
     + EXTRACT( MINUTE FROM vDifference ) *    60
     + EXTRACT( SECOND FROM vDifference )
  INTO
    vSeconds 
  FROM DUAL ;

  RETURN vSeconds ;

END intervalToSeconds ; 
Error: User Rate Limit Exceeded Ben
Error: User Rate Limit Exceededsqlfiddle.com/#!4/42d23/1Error: User Rate Limit Exceeded Ben
19

Error: User Rate Limit Exceeded

[email protected]> select interval_difference
      2        ,sysdate + (interval_difference * 86400) - sysdate as fract_sec_difference
      3  from   (select systimestamp - (systimestamp - 1) as interval_difference
      4          from   dual)
      5 ;

INTERVAL_DIFFERENCE                                                             FRACT_SEC_DIFFERENCE
------------------------------------------------------------------------------- --------------------
+000000001 00:00:00.375000                                                                 86400,375

Error: User Rate Limit Exceeded

[email protected]> select interval_difference
      2        ,abs(extract(second from interval_difference) +
      3        extract(minute from interval_difference) * 60 +
      4        extract(hour from interval_difference) * 60 * 60 +
      5        extract(day from interval_difference) * 60 * 60 * 24) as your_sec_difference
      6        ,sysdate + (interval_difference * 86400) - sysdate as fract_sec_difference
      7        ,round(sysdate + (interval_difference * 86400) - sysdate) as sec_difference
      8        ,round((sysdate + (interval_difference * 86400) - sysdate) * 1000) as millisec_difference
      9  from   (select systimestamp - (systimestamp - 1) as interval_difference
     10          from   dual)
     11  /

INTERVAL_DIFFERENCE                                                             YOUR_SEC_DIFFERENCE FRACT_SEC_DIFFERENCE SEC_DIFFERENCE MILLISEC_DIFFERENCE
------------------------------------------------------------------------------- ------------------- -------------------- -------------- -------------------
+000000001 00:00:00.515000                                                                86400,515            86400,515          86401            86400515

[email protected]> 
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededstackoverflow.com/a/17413839/458741 Ben

Похожие вопросы