Difference between 2 timestamps

I don't know why my results give me 0. I'm doing a simple date difference. Here is my code:

< cfset nowtime = now() >

< cfif DateDiff ("s", getpost.dtstamp, nowtime) lt 60 >

< cfset subsist = DateDiff ("s", getpost.dtstamp, nowtime) & "seconds ago" >

< cfelseif DateDiff ("m", getpost.dtstamp, nowtime) lt 60 >

< cfset subsist = DateDiff ("m", getpost.dtstamp, nowtime) & "minutes ago" >

< cfelseif DateDiff ('h', getpost.dtstamp, nowtime) lte 23 >

< cfset subsist = DateDiff ("h", getpost.dtstamp, nowtime) & "hours" >

< cfelseif DateDiff ("d", v.dtstamp, nowtime) lte 7 >

< cfset subsist = DateDiff ("d", getpost.dtstamp, nowtime) & "days" >

< cfelse >

< cfset subsist = dateformat (getpost.dtstamp, "mmmm dd") >

< / cfif >

When I view the original variables, it says:

getPost.dtstamp = 2012-03-10 17:33:25.0 I do not know whence cette.0 because the database does not show that.

now = {ts ' 2012-03-12 16:16:02 '}

I get 0.

Well, that explains it. You have the wrong unit of DateDiff.  "m" means for months, not minutes.

Tags: ColdFusion

Similar Questions

  • difference between two timestamps

    Hi gurus,

    I have a procedure which has 2 input parameters of type timestamp. I need to find the difference between these two stamps and be converted to a timestamp and return. Help, please

    Diifernce between two timestamps is interval. You can not convert the difference between two timestamp timestamp and it makes no sense. What you expect:

    25/06/2014 11:25:37.524000 - 13:07:22.987654 20/06/2014

    SY.

  • How to store the difference between two timestamps as a number?

    Hello
    I need to find the difference between 2 variables of timestamp and the result will be stored as a number in minutes?
    as
    declare
    timestamp (7) of the fir_timestamp: = 1 January 2012 13:30 ';
    timestamp (7) of the sec_timestamp: = 1 January 2012 14:00 ';
    c number;
    Start
    c:=((sec_timestamp-fir_timestamp)/(24*60));
    dbms_output.put_line (c);
    end;

    962813 wrote:
    declare

    -fir_timestamp timestamp (7): ='01 - jan - 2012 13:30 ';
    timestamp (7) of the sec_timestamp: = 1 January 2012 14:00 ';  Incorrect type declaration

    fir_timestamp timestamp: = 1st January 12 01.30.00.000000 PM';
    sec_timestamp timestamp: = 1st January 12 02.00.00.000000 PM';
    c number;
    Start
    c: = ABS ((extrait (HEURE de sec_timestamp) - extract (fir_timestamp TIME)) * 60) +.
    ABS ((extrait (MINUTE de sec_timestamp) - extract (fir_timestamp MINUTE)));
    dbms_output.put_line (' interval Min Total:-' | c);
    end;
    /
    declare
    *
    ERROR on line 1:
    ORA-01830: date format picture ends before converting all of the input string
    ORA-06512: at line 6

    Follow what Paul has done...

    In fact, you do not need timestamp, date data type is enough

    SQL> declare
      2     fir_timestamp date :=
      3        to_date('01-jan-2012 13:30:00','dd-mon-yyyy hh24:mi:ss');
      4     sec_timestamp date :=
      5        to_date('01-jan-2012 14:00:00','dd-mon-yyyy hh24:mi:ss');
      6     c number;
      7  begin
      8     c:= round((sec_timestamp-fir_timestamp)*24*60);
      9     dbms_output.put_line(c);
     10  end;
     11  /
    30
    
    PL/SQL procedure successfully completed.
    

    If you want to place on timestamp

    SQL> declare
      2     fir_timestamp timestamp :=
      3        to_timestamp('01-jan-2012 13:30:00','dd-mon-yyyy hh24:mi:ss');
      4     sec_timestamp timestamp :=
      5        to_timestamp('01-jan-2012 14:00:00','dd-mon-yyyy hh24:mi:ss');
      6     c number;
      7  begin
      8     c:= round((
      9     to_date(to_char(sec_timestamp,'ddmmyyyyhh24miss'),
     10             'ddmmyyyyhh24miss')-
     11          to_date(to_char(fir_timestamp,'ddmmyyyyhh24miss'),
     12             'ddmmyyyyhh24miss')
     13           )*24*60);
     14     dbms_output.put_line(c);
     15  end;
     16  /
    30
    
  • Difference between 2 timestamps in seconds

    Can someone tell me how to subtract 2 timestamps and
    get the difference in seconds? does not "rip."
    He always gives a value between 0 and 59, I want total
    seconds, not the seconds part of the interval.

    I use Oracle Database 10 g Express Edition Release 10.2.0.1.0
    SQL> @id8
    SQL> drop   table holder ;
    
    Table dropped.
    
    SQL> create table holder (
      2  beg_date timestamp,
      3  end_date timestamp)
      4  /
    
    Table created.
    
    SQL> INSERT INTO HOLDER VALUES(to_timestamp('2009-07-16:19:00:01.50','YYYY-MM-DD:HH24:MI:SS.FF'),
      2                        to_timestamp('2009-08-17:20:00','YYYY-MM-DD:HH24:MI'));
    
    1 row created.
    
    SQL> COMMIT;
    
    Commit complete.
    
    SQL> SELECT EXTRACT (DAY    FROM (END_DATE-BEG_DATE))*24*60*60+
      2           EXTRACT (HOUR   FROM (END_DATE-BEG_DATE))*60*60+
      3           EXTRACT (MINUTE FROM (END_DATE-BEG_DATE))*60+
      4           EXTRACT (SECOND FROM (END_DATE-BEG_DATE)) DELTA
      5  from holder
      6  /
    
         DELTA
    ----------
     2768398.5
    
  • Type of data resulting from the difference between two timestamps

    Hi, I have a simple question.
    I have two TIMESTAMP A and B variables. Now I want to subtract one B - A. What type of data as a result of this subtraction?
    Would Shouln t TIMESTAMP again?

    Consider this example:
    DECLARE
       vdat_Begin        TIMESTAMP;
       vdat_End          TIMESTAMP;
       vdat_Difference   TIMESTAMP;
    BEGIN
       vdat_Difference := vdat_End - vdat_Begin;   -- this doesn't work
       vdat_Difference := TO_TIMESTAMP(vdat_End - vdat_Begin);   -- this works
    END;
    /
    
    PLS-00382: expression is of wrong type
    Thanks for help.

    xxsawer wrote:
    Hi, I have a simple question.
    I have two TIMESTAMP A and B variables. Now I want to subtract one B - A. What type of data as a result of this subtraction?
    Would Shouln t TIMESTAMP again?

    Consider this example:

    DECLARE
    vdat_Begin        TIMESTAMP;
    vdat_End          TIMESTAMP;
    vdat_Difference   TIMESTAMP;
    BEGIN
    vdat_Difference := vdat_End - vdat_Begin;   -- this doesn't work
    vdat_Difference := TO_TIMESTAMP(vdat_End - vdat_Begin);   -- this works
    END;
    /
    
    PLS-00382: expression is of wrong type
    

    Thanks for help.

    No, as stated, there will be an interval.

  • calculate the difference between two timestamps

    Hello
    I'm new in PL/SQL and have the following problem. In our application, there are events that insert records into a table with a parameter "processing_date" of type DATE (when they will be processed). For a new type of events, I have to plan the 'processing_date' at 18:00 on the day of insertion, if the event has happened until 18:00 and sysdate if event occurs after 18:00.
    In a pseudo-code that will be
    IF to_char(SYSDATE,'HH24:MI:SS') > 17:59 min 59 s ' THEN - the event took place after 18:00
    processind_date: = sysdate;
    Else - the event has happened until 18:00
    processing_date: = current_timestamp + ('timestamp at 18:00 ' - current_timestamp); -> processing_date: = today at 18:00
    END IF;

    I'll appreciate any help.

    Thank you.

    dariusgeo wrote:
    processing_date: = current_timestamp + ('timestamp at 18:00 ' - current_timestamp); -> processing_date: = today at 18:00

    For 18:00 of the current date, you can do:

     processing_date := TRUNC(SYSDATE)+18/24;
    

    TRUNC will be truncates the current date ' 00:00:00 '.
    Add 18/24 means add 18 hours (1 day / 24 * 18).

    Kind regards.
    Al

    Published by: Alberto Faenza 22 may 2013 22:07

  • Difference between Sysdate and trunc (sysdate)?

    SYSDATE and trunc (sysdate) both return the current date.

    So I would like to know is there a difference between them?

    Thank you

    DATEs in Oracle ALWAYS have a portion of time (what you call a timestamp). Using tronque() on a DATE fixed the part time at midnight that day there

  • Difference between 2 dates using PHP

    Hello

    Having some problems with the calculation of the difference between 2 dates.

    I noticed that about half of the results output 552 months... where is should be approximately 24 months...

    I also noticed that records that display this incorrect calculation having the month following the date less than the current month, it fixed $date2 as 01/01/1970

    This is the code:

    <? PHP

    Calculate the remaining months

    $date1 = date('d/m/Y');

    $date2 = $renewal_row ["enddate"];

    $date2 = date (a/m/Y ", strtotime (str_replace ('. ', ' ' ', $renewal_row [' enddate ']', $renewal_row ['enddate']))");

    $diff = abs (strtotime ($date2) - strtotime ($date1));

    $years = floor ($diff / (365 * 60 * 60 * 24));

    $months = floor (($diff-$years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24));

    $days = floor (($diff-$years * 365 * 60 * 60 * 24-$months * 30 * 60 * 60 * 24) / (60 * 60 * 24));

    printf ("%d years, %d months, %d days\n", $years, $months, $days);

    $months_remaining = ($years * 12) + $months;

    ? >

    <? PHP echo "$date1 ='.strtotime ($date1).» ('. $date1.) ") date2 = '.strtotime ($date2).' ('. $date2.) ('') = Difference'. $diff;? >

    The date correct difference between these dates:

    $date1 = 1452038400 (06/01/2016) date2 = 1520035200 (03/03/2018) difference = 67996800

    Day with incorrect difference:

    $date1 = 1452038400 (06/01/2016) date2 = 1452038400 difference =(20/11/2016)

    Note that if the $date2 month exceeds the month current (June) it messes up.

    Any help would be appreciated!

    Assuming that this ["enddate"] $renewal_row is stored in a MySQL/MariaDB DATE, DATETIME, or TIMESTAMP column.

    $now = new DateTime();

    $end = new DateTime ($renewal_row ['enddate']);

    $time_remaining = $now-> diff ($end);

    echo $time_remaining-> format (' %m month %d days ");

  • Setting up a query - difference between 'A-lines' and 'E '.

    Hi all

    I use 11g R2 and I'm trying to deal with a request for some time now, but still no luck. Watching my plan to explain, I have a difference between my E-lines and my A. I can't understand why. Almost all my E-lines are equal to 1. All my paintings are statistics updated with as histograms.

    What else can I check?

    Thank you very much.
    /* 65671b48 */
    select distinct T1830.CAL_DT as c1,
         T17.NOM_CONTRACTANT as c2,
         T24.NOM_CONTRAT as c3,
         T2098.NAME as c4,
         T210.NOM_FLUIDE as c5,
         T160.GEO_CODE as c6,
         T160.ADDRESS as c7,
         T160.COMMUNE as c8,
         T122.NOM_OFFRE as c9,
         T1011.SERIAL_NUMBER as c10,
         T1191.METER_MODULE_REF_NO as c11,
         T2098.CUSTOM_DATA as c12,
         T217.NOM_TYP_PDC as c13,
         T949.RADIO_MODULE_REF_NO as c14,
         T786.ASSOCIATE_DATE as c15,
         T786.INSTALLATION_DATE as c16,
         T786.NB_DAYS_10_WITHOUT as c17,
         ( TRUNC( TO_DATE('2013-02-21' , 'YYYY-MM-DD') ) - TRUNC(  cast(T786.INDEX_BEFORE_MIDNIGHT_DATE as TIMESTAMP ) ) ) as c18,
         ( TRUNC( TO_DATE('2013-02-21' , 'YYYY-MM-DD') ) - TRUNC(  cast(T786.QMIN_LAST_DATE as TIMESTAMP ) ) ) as c19,
         floor(T786.INDEX_COUNT_10 * 100 / (4 * 10)) as c20,
         floor(T786.INDEX_COUNT_30 * 100 / (4 * 30)) as c21,
         T786.NB_RECEIVERS_TRANS as c22,
         T2158.TXT_PERFORMANCE as c23,
         T2186.TXT_DIAGNOSYS as c24
    from 
         DIM_CUSTOMER T2098 /* D6 Customer */ ,
         DIM_PERFORMANCE T2158 /* D7 Performance */ ,
         (
              DIM_OFFRE T122 inner join (
                   DIM_CONTRAT T24 inner join (
                        DIM_CONTRACTANT T17 inner join (
                             (
                                  (
                                       (
                                            DIM_RADIO_MODULE T949 /* D1 Radio Module */  inner join (
                                                 DIM_METER_MODULE T1191 /* D2 Meter Module */  inner join (
                                                      DIM_SERVICE_POINT T160 inner join (
                                                           DIM_DATE T1830 /* D5 Date */  inner join (
                                                                DIM_METER T1011 /* D4 Meter */  inner join FAC_DAILY_TRANS_PERFORM T786 /* F1 Fac Daily Trans Perform */  On T786.METER_KEY = T1011.METER_KEY) On T786.DATE_KEY = T1830.DATE_KEY) On T160.SERVICE_POINT_KEY = T786.SERVICE_POINT_KEY) On T786.METER_MODULE_KEY = T1191.METER_MODULE_KEY) On T786.RADIO_MODULE_KEY = T949.RADIO_MODULE_KEY) inner join DIM_TYP_PDC T217 On T160.TYP_PDC_KEY = T217.TYP_PDC_KEY) inner join DIM_TYP_FLUIDE T210 On T160.FLUIDE_KEY = T210.FLUIDE_KEY) inner join REL_SERVICE_POINT_CONTRAT T298 On T160.SERVICE_POINT_KEY = T298.SERVICE_POINT_KEY) On T17.CONTRACTANT_KEY = T298.CONTRACTANT_KEY) On T17.CONTRACTANT_KEY = T24.CONTRACTANT_KEY and T24.CONTRAT_KEY = T298.CONTRAT_KEY) On T122.OFFRE_KEY = T298.OFFRE_KEY) left outer join 
              DIM_DIAGNOSYS T2186 /* D8 Diagnosys */  On T786.DIAGNOSYS_KEY = T2186.DIAGNOSYS_KEY
    where  ( T786.CUSTOMER_KEY = T2098.CUSTOMER_KEY and T17.NOM_CONTRACTANT = 'ER Rhône Alpes Auvergne' and T24.NOM_CONTRAT = 'CHAVANOZ' and T786.PERFORMANCE_KEY = T2158.PERFORMANCE_KEY and T1830.CAL_DT = TO_DATE('2013-02-09 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') ) 
    order by c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24
    
    
    Plan hash value: 3221242991
     
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                      | Name                      | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  | Writes |  OMem |  1Mem |  O/1/M   | Max-Tmp |
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                               |                           |      1 |        |    311 |00:01:56.92 |   30325 |  19042 |     31 |       |       |          |         |
    |   1 |  SORT ORDER BY                                 |                           |      1 |     90 |    311 |00:01:56.92 |   30325 |  19042 |     31 |   279K|   279K|          |   16384 |
    |   2 |   HASH UNIQUE                                  |                           |      1 |     90 |    311 |00:01:56.89 |   30318 |  19011 |      0 |   702K|   702K|     1/0/0|         |
    |   3 |    NESTED LOOPS                                |                           |      1 |        |    311 |00:01:56.88 |   30318 |  19011 |      0 |       |       |          |         |
    |   4 |     NESTED LOOPS                               |                           |      1 |     90 |    311 |00:01:54.84 |   30007 |  18700 |      0 |       |       |          |         |
    |   5 |      NESTED LOOPS                              |                           |      1 |     90 |    311 |00:01:52.84 |   29383 |  18396 |      0 |       |       |          |         |
    |   6 |       NESTED LOOPS                             |                           |      1 |     90 |    311 |00:01:47.87 |   28448 |  17783 |      0 |       |       |          |         |
    |   7 |        NESTED LOOPS                            |                           |      1 |     90 |    311 |00:01:43.29 |   27513 |  17181 |      0 |       |       |          |         |
    |*  8 |         HASH JOIN                              |                           |      1 |     90 |    311 |00:01:39.18 |   26571 |  16559 |      0 |   909K|   909K|     1/0/0|         |
    |   9 |          TABLE ACCESS FULL                     | DIM_PERFORMANCE           |      1 |      5 |      5 |00:00:00.01 |       6 |      6 |      0 |       |       |          |         |
    |  10 |          NESTED LOOPS OUTER                    |                           |      1 |     90 |    311 |00:01:39.16 |   26565 |  16553 |      0 |       |       |          |         |
    |  11 |           NESTED LOOPS                         |                           |      1 |     90 |    311 |00:01:39.16 |   26565 |  16553 |      0 |       |       |          |         |
    |* 12 |            HASH JOIN                           |                           |      1 |    140 |    311 |00:00:04.98 |    1541 |   1170 |      0 |  1000K|  1000K|     1/0/0|         |
    |  13 |             TABLE ACCESS FULL                  | DIM_TYP_FLUIDE            |      1 |      3 |      3 |00:00:00.01 |       6 |      6 |      0 |       |       |          |         |
    |* 14 |             HASH JOIN                          |                           |      1 |    140 |    311 |00:00:04.97 |    1535 |   1164 |      0 |   955K|   955K|     1/0/0|         |
    |  15 |              TABLE ACCESS FULL                 | DIM_TYP_PDC               |      1 |      3 |      3 |00:00:00.01 |       6 |      6 |      0 |       |       |          |         |
    |  16 |              NESTED LOOPS                      |                           |      1 |        |    311 |00:00:04.96 |    1529 |   1158 |      0 |       |       |          |         |
    |  17 |               NESTED LOOPS                     |                           |      1 |    140 |    311 |00:00:02.84 |    1218 |    853 |      0 |       |       |          |         |
    |* 18 |                HASH JOIN                       |                           |      1 |    140 |    311 |00:00:00.83 |     594 |    586 |      0 |   880K|   880K|     1/0/0|         |
    |  19 |                 TABLE ACCESS FULL              | DIM_OFFRE                 |      1 |     22 |     22 |00:00:00.02 |       6 |      6 |      0 |       |       |          |         |
    |* 20 |                 HASH JOIN                      |                           |      1 |    140 |    311 |00:00:00.81 |     588 |    580 |      0 |   769K|   769K|     1/0/0|         |
    |  21 |                  NESTED LOOPS                  |                           |      1 |        |      1 |00:00:00.02 |      11 |     11 |      0 |       |       |          |         |
    |  22 |                   NESTED LOOPS                 |                           |      1 |      1 |      1 |00:00:00.02 |      10 |     10 |      0 |       |       |          |         |
    |  23 |                    NESTED LOOPS                |                           |      1 |      1 |      1 |00:00:00.02 |       9 |      9 |      0 |       |       |          |         |
    |  24 |                     TABLE ACCESS BY INDEX ROWID| DIM_DATE                  |      1 |      1 |      1 |00:00:00.01 |       3 |      3 |      0 |       |       |          |         |
    |* 25 |                      INDEX UNIQUE SCAN         | AK_DATE                   |      1 |      1 |      1 |00:00:00.01 |       2 |      2 |      0 |       |       |          |         |
    |* 26 |                     TABLE ACCESS FULL          | DIM_CONTRAT               |      1 |      1 |      1 |00:00:00.01 |       6 |      6 |      0 |       |       |          |         |
    |* 27 |                    INDEX UNIQUE SCAN           | PK_CONTRACTANT_KEY        |      1 |      1 |      1 |00:00:00.01 |       1 |      1 |      0 |       |       |          |         |
    |* 28 |                   TABLE ACCESS BY INDEX ROWID  | DIM_CONTRACTANT           |      1 |      1 |      1 |00:00:00.01 |       1 |      1 |      0 |       |       |          |         |
    |  29 |                  TABLE ACCESS FULL             | REL_SERVICE_POINT_CONTRAT |      1 |  55048 |  55048 |00:00:00.48 |     577 |    569 |      0 |       |       |          |         |
    |* 30 |                INDEX UNIQUE SCAN               | PK_SP_KEY                 |    311 |      1 |    311 |00:00:02.01 |     624 |    267 |      0 |       |       |          |         |
    |  31 |               TABLE ACCESS BY INDEX ROWID      | DIM_SERVICE_POINT         |    311 |      1 |    311 |00:00:02.11 |     311 |    305 |      0 |       |       |          |         |
    |  32 |            TABLE ACCESS BY GLOBAL INDEX ROWID  | FAC_DAILY_TRANS_PERFORM   |    311 |      1 |    311 |00:01:34.17 |   25024 |  15383 |      0 |       |       |          |         |
    |* 33 |             INDEX RANGE SCAN                   | FAC_DAY_TRAN_PERF_ID      |    311 |      1 |    311 |00:00:44.35 |   14525 |   7680 |      0 |       |       |          |         |
    |  34 |           TABLE ACCESS BY INDEX ROWID          | DIM_DIAGNOSYS             |    311 |      1 |      0 |00:00:00.01 |       0 |      0 |      0 |       |       |          |         |
    |* 35 |            INDEX UNIQUE SCAN                   | PK_DIAGNOSYS_KEY          |    311 |      1 |      0 |00:00:00.01 |       0 |      0 |      0 |       |       |          |         |
    |  36 |         TABLE ACCESS BY INDEX ROWID            | DIM_RADIO_MODULE          |    311 |      1 |    311 |00:00:04.11 |     942 |    622 |      0 |       |       |          |         |
    |* 37 |          INDEX UNIQUE SCAN                     | PK_RADMODKEY              |    311 |      1 |    311 |00:00:01.93 |     624 |    304 |      0 |       |       |          |         |
    |  38 |        TABLE ACCESS BY INDEX ROWID             | DIM_METER_MODULE          |    311 |      1 |    311 |00:00:04.58 |     935 |    602 |      0 |       |       |          |         |
    |* 39 |         INDEX UNIQUE SCAN                      | PK_METMODKEY              |    311 |      1 |    311 |00:00:02.00 |     624 |    301 |      0 |       |       |          |         |
    |  40 |       TABLE ACCESS BY INDEX ROWID              | DIM_METER                 |    311 |      1 |    311 |00:00:04.96 |     935 |    613 |      0 |       |       |          |         |
    |* 41 |        INDEX UNIQUE SCAN                       | PK_METER                  |    311 |      1 |    311 |00:00:02.42 |     624 |    304 |      0 |       |       |          |         |
    |* 42 |      INDEX UNIQUE SCAN                         | PK_CUSTOMER               |    311 |      1 |    311 |00:00:01.99 |     624 |    304 |      0 |       |       |          |         |
    |  43 |     TABLE ACCESS BY INDEX ROWID                | DIM_CUSTOMER              |    311 |      1 |    311 |00:00:02.04 |     311 |    311 |      0 |       |       |          |         |
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       8 - access("T786"."PERFORMANCE_KEY"="T2158"."PERFORMANCE_KEY")
      12 - access("T160"."FLUIDE_KEY"="T210"."FLUIDE_KEY")
      14 - access("T160"."TYP_PDC_KEY"="T217"."TYP_PDC_KEY")
      18 - access("T122"."OFFRE_KEY"="T298"."OFFRE_KEY")
      20 - access("T24"."CONTRAT_KEY"="T298"."CONTRAT_KEY" AND "T17"."CONTRACTANT_KEY"="T298"."CONTRACTANT_KEY")
      25 - access("T1830"."CAL_DT"=TO_DATE(' 2013-02-09 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      26 - filter("T24"."NOM_CONTRAT"='CHAVANOZ')
      27 - access("T17"."CONTRACTANT_KEY"="T24"."CONTRACTANT_KEY")
      28 - filter("T17"."NOM_CONTRACTANT"='ER Rhône Alpes Auvergne')
      30 - access("T160"."SERVICE_POINT_KEY"="T298"."SERVICE_POINT_KEY")
      33 - access("T786"."DATE_KEY"="T1830"."DATE_KEY" AND "T160"."SERVICE_POINT_KEY"="T786"."SERVICE_POINT_KEY")
      35 - access("T786"."DIAGNOSYS_KEY"="T2186"."DIAGNOSYS_KEY")
      37 - access("T786"."RADIO_MODULE_KEY"="T949"."RADIO_MODULE_KEY")
      39 - access("T786"."METER_MODULE_KEY"="T1191"."METER_MODULE_KEY")
      41 - access("T786"."METER_KEY"="T1011"."METER_KEY")
      42 - access("T786"."CUSTOMER_KEY"="T2098"."CUSTOMER_KEY")

    Chiwatel wrote:

    I use 11g R2 and I'm trying to deal with a request for some time now, but still no luck. Watching my plan to explain, I have a difference between my E-lines and my A. I can't understand why. Almost all my E-lines are equal to 1. All my paintings are statistics updated with as histograms.

    A lines gives you the total number of rows that were sent by content (RowSource). E - lines you gives the expected number of rows with content (RowSource) expect to spend on EVERY TIME it is called. This means that you should compare A-lines with begins * E-lines.

    In the example you showed, a lot of your miniatures of E-lines are 1 because the operation is a unique index analysis, or access to the table as a result of a unique index analysis.

    Concerning
    Jonathan Lewis

  • How to find the difference between two dates in time except Sunday

    Hi all

    I have a table, as shown below.
    SQL> select * from test;
    
    TR_ID                                              CREATE_TIME                                                                       CODE
    -------------------------------------------------- --------------------------------------------------------------------------- ----------
    S12341                                             05-JUN-12 12.20.52.403000 AM                                                      1003
    S12342                                             11-JUN-12 11.15.33.182000 AM                                                      1003
    S12342                                             07-JUN-12 12.00.36.573000 PM                                                      1002
    S12343                                             20-JUN-12 12.34.37.102000 AM                                                      1003
    S12343                                             15-JUN-12 11.34.27.141000 PM                                                      1002
    S12344                                             01-JUL-12 10.01.06.657000 PM                                                      1002
    S12344                                             06-JUL-12 12.01.04.188000 AM                                                      1003
    S12341                                             31-MAY-12 11.20.38.529000 PM                                                      1002
    I would like to know the difference between same tr_ids create_time, which should give out in hours except Sunday.

    For example:

    TR_ID: S12344
    1002_Create_time: July 1, 12 PM 10.01.06.657000 (i.e. Sunday)
    1003_Create_time: 12.01.04.188000 AM 6 July 12

    1002 create time is 22:00 Sunday.

    If the query must exclude only the hours of Sunday which is 10 p.m. to Monday 00 h which is 2 Hrs.

    I tried the sub query after doing a search on this forum but I am not getting the desired output.
    SELECT count(*) FROM (SELECT ROWNUM RNUM,tr_id,create_time CT_1002 FROM test c WHERE c.tr_id='S12344' and 
    ROWNUM <= (select (cast(a.create_time as date)-cast((select create_time from test b where a.tr_id=b.tr_id and code=1002) as date)) 
    from test a where a.code=1003 and a.tr_id=c.tr_id) + 1) d 
    WHERE to_char(cast((select create_time from test e where e.tr_id=d.tr_id and code=1002) as date) + RNUM - 1, 'DY') NOT IN('SUN');
    Need help to get the desired o/p

    Hello

    If I unederstand the problem correctly, that's what you want:

    WITH       got_extrema     AS
    (
         SELECT       tr_id
         ,       CAST (MIN (create_time) AS DATE)     AS start_date
         ,       CAST (MAX (create_time) AS DATE)     AS end_date
         FROM       test
         GROUP BY  tr_id
    )
    SELECT       tr_id
    ,       start_date, end_date          -- If wanted
    ,       24 * ( ( ( TRUNC (end_date,   'IW')          -- Count -1 day for every full week
                        - TRUNC (start_date, 'IW')
                 )
               / -7
                  )
                + LEAST ( end_date               -- If end_date is a Sunday
                            , TRUNC (end_date, 'IW') + 6     -- consider it 00:00:00 on Sunday
                     )
                - CASE
                          WHEN  start_date >= TRUNC (start_date, 'IW') + 6     -- If start_date is a Sunday
                   THEN  TRUNC (start_date, 'IW') + 6               -- consider it 00:00:00 Sunday
                   ELSE  start_date
                      END
                )     AS total_hours
    FROM      got_extrema
    ;
    

    I guess that you don't need to worry about fractions of a second. As you did in the code you have posted, I am to convert the TIMESTAMP to date values, because of DATE arithmetic and functions are so much better than what is available for timestamps.

    Basically, it's just to find the number of days between start_date and end_date and multiplying by 24, with these twists:
    (a) 1 day is deducted for each week between start_date and end_date
    (b) if End_date is a Sunday, none of the end_date himself hours are counted
    (c) If start_date is a Sunday, then all the start_date himself hours are counted. Why these hours should be counted? Because 1 day is already being deducted for the week which includes start_date, which contains only this Sunday.

    TRUNC (dt, 'IW') is the beginning of the ISO week containing dt; in other words, 00:00:00 the or before the dt last Monday. This is not the NLS parameters.

    Of course, I can't test without some sample data and the exact results you want from these data. You may need a little something more If start_date and end_date are both on the same Sunday.
    Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
    Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}

  • How to find the difference between two dates in the presentation layer

    Hi gurus,

    Hello to everyone. Today, I came with the new requirement.


    I need to know the difference between a date and the current date in the formula column application presentation layer.by.



    Thank you and best regards,
    Prates

    Hi Navin,

    TIMESTAMPDIFF function first determines the timestamp component that corresponds to the specified interval setting. For example, SQL_TSI_DAY corresponds to the day component and SQL_TSI_MONTH corresponds to the component "month".

    If you want to display the difference between two dates in days using SQL_TSI_DAY, unlike butterflies SQL_TSI_MONTH and so on...

    hope you understand...

    Award points and to close the debate, if your question is answered.

    See you soon,.
    Aravind

  • What is the difference between these two JKM and when to use that one.

    Please tell the difference between these two.
    JKM Oracle compatible o JKM Oracle compatible (Date of update)

    Basic difference is in the obligation.

    JKM Oracle compatible (Date of update) wants a DATE/TIMESTAMP column in the source tables (s) who will get inserted/updated updated by the source application. ODI will capture the data modified, based on the value of this column. Only the DELETION part requires a trigger to keep track of deletion happening at source one or more tables.

    Where as JKM uniform Oracle does not require any which TIMESTAMP column in the tables of the source (s). It uses triggers to keep track of the INSERT/UPDATE/DELETE happening in the source.

    Compatible JKM Oracle performance (Update Date) is preferable, because it will create a little over the head on your source system. SO if you have a DATE/TIMESTAMP column in the tables of the source (s) that gets inserted/updated by the source application, then go JKM Oracle compatible (Date of update).

    Otherwise search JKM consistent Oracle.

    Thank you
    Fati

  • Difference between Teminale and AppleScript?

    What is the difference between two different terminal applications and apple Script on mac?

    Terminal is the command-line from your computer, AppleScript is a language of code developed by apple, and AppleScript Editor is a code editor for AppleScript.

  • Difference between different models (sold in different regions) of the iPhone 7

    I'm traveling to the Japan, and it turns out that my phone broke. So, I plan to buy iPhone 7. But I noticed that there are different models according to the countries or regions. According to Apple customer service, it has to do with different bands of LTE in different regions. But exactly the same bands that WE supported the Japanese model (which is completely separate from all other) / version of the EU with the exception of it's CDMA.  She would work very well after my return to Europe (Germany)? Where can I buy non-CDMA, GSM version for the Japan as well.

    Here is the link showing the differences between the various models of iPhone 7.

    You have a question?

  • What is the difference between a Apple Watch Series II and the Nike Apple Watch?

    I am interested in buying an Apple Watch, but I don't really understand what are the difference between the two.

    Hello

    Information about the models of series 2 Apple Watch (including Apple Watch Nike +) are available here:

    https://www.Apple.com/watch/

Maybe you are looking for