Count between two dates.

dear friends
i want fetch count between two dates.
my query is like below.
SELECT (to_date('19-mar-2012','dd-mm-yyyy')-to_date('01-apr-2012','dd-mm-yyyy')) FROM dual
its given out like -13 but i want in positive mod like 13 only not '-' Sign.

just use abs() function to your query to get the positive value
SELECT abs(to_date('19-mar-2012','dd-mm-yyyy')-to_date('01-apr-2012','dd-mm-yyyy')) diff FROM dual

Similar Messages

  • Javascript anomoly on day count between two dates

    Using ApEx 4.0, I have found an anomoly in some javascript code that calculates the number of days between two dates, the current_date and the past_date. If the past-date is on or before March 10, 2013, and the current_date is between March 10, 2013, and November 3, 2013, the day count will be 1 day less than the actual count. Between November 3, 2013, and November 4, 2013, the count increments by 2, and then the count will be accurate from this date forward.
    Here are examples:
    Mar 10, 2013 = 69 days from 31-DEC-2012
    Mar 11, 2013 = 69 days from 31-DEC-2012
    Mar 12, 2013 = 70 days from 31-DEC-2012
    Nov. 3 2013 = 306 days from 31-DEC-2012
    Nov. 4 2013 = 308 days from 31-DEC-2012
    March 11 should be 70, and March 12 should be 71. November 3 should be 307, and November 4 corrects the wrong count which began March 11.
    Changing the past_date to March 10, 2013 produces the following:
    10-Mar-2013 = 0 days from 10-Mar-2013
    11-Mar-2013 = 0 days from 10-Mar-2013
    12-Mar-2013 = 1 days from 10-Mar-2013
    But changing the past_date to March 11, 2013, produces correct numbers:
    11-Mar-2013 = 0 days from 11-Mar-2013
    12-Mar-2013 = 1 days from 11-Mar-2013
    13-Mar-2013 = 2 days from 11-Mar-2013
    I would certainly appreciate anyone's help on identifying the cause of this anomoly. Here is the javascript code:
    var w1= ($v("P48_PAST_DATE"));
    w1 = (w1.toString());
    var vmon = (w1.substr(3,3));
    var vyr = (w1.substr(7));
    var r = (vyr.length);
    if (r == 2)
    vyr = (parseFloat(vyr) + 2000);
    var vday = (w1.substr(0,2));
    var y = (vmon.concat(" ",vday,", ",vyr));
    y = Date.parse(y);
    var w2 = ($v("P48_CURRENT_DATE"));
    var vmon2 = (w2.substr(3,3));
    var vyr2 = (w2.substr(7));
    var vday2 = (w2.substr(0,2));
    var x = (vmon2.concat(" ",vday2,", ",vyr2));
    x = Date.parse(x);
    var numdays = (x - y);
    numdays = (Math.floor(numdays / 86400000));
    $s("P48_NUMBEROFDAYS",numdays);

    Did you google for something like "javascript number of days between two dates". I think you will find the explanation in this observation:
    This method doesn't work properly if there's a daylight savings jump between the two dates.
    There are examples to be found to calculate the difference between two dates.

  • How to count number of sundays between two dates

    Hi
    I want number of Sundays between two dates
    example
    number of Sundays count between '01-04-2013' and '30-04-2013' in one select query I have to include this as sub query in my select statement.

    Hi,
    ChakravarthyDBA wrote:
    Hi
    I want number of Sundays between two dates
    example
    number of Sundays count between '01-04-2013' and '30-04-2013' in one select query I have to include this as sub query in my select statement.Here's one way:
    SELECT       early_date
    ,       late_date
    ,       ( TRUNC (late_date + 1, 'IW')
           - TRUNC (early_date,        'IW')
           ) / 7       AS sundays
    FROM       table_x
    ;This does not depend on your NLS settings.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Point out where the statment above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Count days between two dates without weekend

    Hi,
    I need a solution in query or another thread, that returns the count of days between two dates without consider weekend (saturday and sunday) , I have the columns of type Date, and the return need in format of hours in one column hh:mm:ss and days in another column.
    Regards
    Jonas

    Hi and welcome to the forum.
    Keep in mind that you can do a search on this forum.
    Your question has been asked before.
    Some other pointers:
    http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551242712657900129
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:185012348071

  • How to count the number of Fridays and Saturdays between two dates

    Hi every one ... If we want to count the number of Fridays and Saturdays between two dates, how would we do that ? !
    Dates are ( 11-Feb-2010) to (19-May-2010)
    how to do it in SQL
    Edited by: khalidoracleit on Jul 28, 2010 5:51 AM

    some nice coding here, I'm still amazed with what some people can do with "connect by". But I agree with some statements here that this can take "time", and to be honest, it's funny to see it working, but if you do not have a computer, just a calendar and some paper, would you go for "counting" so there must be a better solution?
    The best working math in here is done by Aketi Jyuuzou, who writes so good English that I wonder why he still insists that he doesn't ;-)
    Anyhow I "translated" that code to English, and I really like that math. Math is math and data is data.
    ALTER SESSION SET NLS_DATE_LANGUAGE='ENGLISH';
    WITH my_dates AS (
    SELECT to_date('20100211','yyyymmdd') start_date,to_date('20100519','yyyymmdd') end_date FROM DUAL
    UNION ALL
    SELECT to_date('20100211','yyyymmdd') start_date,to_date('20100214','yyyymmdd') end_date FROM DUAL
    UNION ALL
    SELECT to_date('20100211','yyyymmdd') start_date,to_date('20100213','yyyymmdd') end_date FROM DUAL
    UNION ALL
    SELECT to_date('20100211','yyyymmdd') start_date,to_date('20100212','yyyymmdd') end_date FROM DUAL
    SELECT to_char(start_date,'DD.MM.YYYY') start_date,to_char(end_date,'DD.MM.YYYY') end_date,
           to_char(start_date,'DAY') start_weekday,to_char(end_date,'DAY') end_weekday,
           end_date-start_date day_difference,
           (next_day(end_date,'FRIDAY')-7
           -next_day(start_date -1,'FRIDAY'))/7+1
           +(next_day(end_date,'SATURDAY')-7
           -next_day(start_date -1,'SATURDAY'))/7+1 as count_of_fr_and_sat
    FROM my_dates;
    START_DATE END_DATE   START_WEEKDAY                        END_WEEKDAY                          DAY_DIFFERENCE         COUNT_OF_FR_AND_SAT   
    11.02.2010 19.05.2010 THURSDAY                             WEDNESDAY                            97                     28                    
    11.02.2010 14.02.2010 THURSDAY                             SUNDAY                               3                      2                     
    11.02.2010 13.02.2010 THURSDAY                             SATURDAY                             2                      2                     
    11.02.2010 12.02.2010 THURSDAY                             FRIDAY                               1                      1                      -- andy

  • How to count days between two dates excluding saterady and sunday

    Hi all
    iam working on oracle sql/plsql.
    In my application , i need to caliculate leave days between two dates excluding saterady and sunday
    Please tell me the solution if any one knows
    thanks in advance ,
    balu

    More modern version:
    WITH date_tab AS
    (SELECT TO_DATE ('&from_date', 'dd-MON-yyyy')
    + LEVEL
    - 1 business_date
    FROM DUAL
    CONNECT BY LEVEL <=
    TO_DATE ('&to_date', 'dd-MON-yyyy')
    - TO_DATE ('&from_date', 'dd-MON-yyyy')
    + 1)
    SELECT business_date
    FROM date_tab
    WHERE TO_CHAR (business_date, 'DY') NOT IN ('SAT', 'SUN');Thank you,
    Tony Miller
    Webster, TX
    Never Surrender Dreams!
    JMS
    If this question is answered, please mark the thread as closed and assign points where earned..

  • No of Fridays in between two date

    Hi all
    What is the Qucikest and easy way to retreive the NO of fridyas in betwen two dates
    Thanks & Regards
    Vivek

    vivekvm wrote:
    Hi all
    What is the Qucikest and easy way to retreive the NO of fridyas in betwen two dates
    Make sure you test the boundary conditions for any solution you get.
    Have you defined exactly what you mean by "in between two dates", for example. do you want to count the end points if one, or both, of them is a friday ?
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to Calculate number of months between two dates

    Hi All,
       In one of the fomr developments, I have to calculate the
    Number of Days
    Number of Months ( Considering Leap Year) provided by the dates, end user enters in the form,
    After going thorugh some forum discussion, I have come to know about so many things which were not clear till now.
    I have gone through various forums too,  some one suggets to make use of FORM CALC and some other JAVA SCRIPT. But the logic i want to build in java script.
    The most interesting point is the DATE object is not getting created when i write  the below code
      var startDate = new DATE(oYear, oMonth, oDay);
    I am still not clear, that really the date object gets created in Adobe form If so the why the alert box is getting populated when i write below lines
    var oTemp = startDate.getFullYear();
    xfa.host.messagebox(oTemp);
    So, there are so many unclear things,
    If any one can help me by suggesting the approach and how to build the logic in the JavaScript I would be really thankful
    Regards
    PavanChand

    Hi,
    ChakravarthyDBA wrote:
    Hi
    I want number of Sundays between two dates
    example
    number of Sundays count between '01-04-2013' and '30-04-2013' in one select query I have to include this as sub query in my select statement.Here's one way:
    SELECT       early_date
    ,       late_date
    ,       ( TRUNC (late_date + 1, 'IW')
           - TRUNC (early_date,        'IW')
           ) / 7       AS sundays
    FROM       table_x
    ;This does not depend on your NLS settings.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Point out where the statment above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Gap Between Two Dates

    Can Anyone tell me how to find out the gap between two dates. Specifically Without counting Saturday and Sunday.

    corlettk wrote:
    <intercession>
    Has anyone written a DateMath class?... it would be handy... the amount (and ugliness) of the code required to do elementary date mathematics with the raw Calendar is appaling.<recess>
    Isn't Java 7 supposed to cure all this headache?
    </recess>

  • Select entries between two dates by converting Unix timestamp in Oracle Dat

    Hi,
    I need to select the entries between two dates from an Oracle db. The Oracle db has a column with Unix timestamps. I use the following querry, but it doesnt seem to be working as desired.
    select count(*) from reporter_status where to_char(FIRSTOCCURRENCE, 'mm-dd-yy') between ('08-07-06') and ('08-08-06');
    FIRSTOCCURRENCE has the Unix timestamps.
    Could anyone help me out with this. Thank you for your help.

    Assuming that it is actually a UNIX timestamp, then it is the number of seconds since Jan 1, 1970, so you need something like:
    SELECT COUNT(*)
    FROM reporter_status
    WHERE TO_DATE('01-Jan-1970', 'dd-mon-yyyy') + (firstoccurrence/24/60/60)
                    BETWEEN TO_DATE('08-07-2006', 'mm-dd-yyyy') AND
                            TO_DATE('08-08-2006, 'mm-dd-yyyy');Did Y2K not teach us anything? Use 4 digit years.
    John

  • Average of a field between two dates

    Hi,
    I have a table with two fields. Date Field and Percentage field. For ex,
    Date Percentage
    1/1/2006 11
    1/4/2006 23
    2/4/2006 34
    11/11/2006 354
    1/4/2007 75
    10/09/2007 67
    2/3/2008 876
    I want to find the average(sum of percentage/total no) of Percentage field between two dates.
    I am passing only the end date. And, the start date I have to find according to the end date.
    For ex,if I am passing the end date as 10/09/2007, starting date should be 1/4/2007.
    And, if I am passing the end date as 11/11/2006, starting date should be 1/4/2006.
    For end date 2/3/2008, start date should be 1/4/2007.
    Starting date is taken as by considering the year end as April to March. So, I have to retrieve the average of the percentage field from April to the selected date as end date.
    thanks

    Getting the sum, number of rows and average since the last 1st of April to the current date :
    SQL> with tbl as
      2  (select to_date('01/01/2006','dd/mm/yyyy') as dt, 11  prct from dual union all
      3   select to_date('01/04/2006','dd/mm/yyyy') as dt, 23  prct from dual union all
      4   select to_date('02/04/2006','dd/mm/yyyy') as dt, 34  prct from dual union all
      5   select to_date('11/11/2006','dd/mm/yyyy') as dt, 354 prct from dual union all
      6   select to_date('01/04/2007','dd/mm/yyyy') as dt, 75  prct from dual union all
      7   select to_date('10/09/2007','dd/mm/yyyy') as dt, 67  prct from dual union all
      8   select to_date('02/03/2008','dd/mm/yyyy') as dt, 876 prct from dual)
      9  select dt, prct,
    10         sum(prct) over (order by dt range between dt-add_months(trunc(add_months(dt,-3),'yyyy'),3) preceding and current row) sum_prct,
    11         count(prct) over (order by dt range between dt-add_months(trunc(add_months(dt,-3),'yyyy'),3) preceding and current row) nb_prct,
    12         avg(prct) over (order by dt range between dt-add_months(trunc(add_months(dt,-3),'yyyy'),3) preceding and current row) avg_prct
    13  from tbl;
    DT             PRCT   SUM_PRCT    NB_PRCT   AVG_PRCT
    01/01/06         11         11          1         11
    01/04/06         23         23          1         23
    02/04/06         34         57          2       28,5
    11/11/06        354        411          3        137
    01/04/07         75         75          1         75
    10/09/07         67        142          2         71
    02/03/08        876       1018          3 339,333333
    7 rows selected.Nicolas.

  • How to query the number of working days between two dates

    I'm looking for a solution to calculate the number of <i>working</i> days between two dates that I can use in a formated search. 
    Calculating the total number of days is pretty straight forward but does anyone know how to take into account the settings in the HLD1 (Holiday Dates) table?

    Hi Eric,
    If you are purely looking to exclude holidays defined in the HLD1 table, then you should be able to do it with the following query
    NOTE: The following query is an example using OINV table and the fields DOCDATE and DOCDUEDATE for a Particular DOCNUM  'xxx'
    If you planning to use within the SAP module then replace DOCDATE and DOCDUEDATE with dynamic field references $[$x.x.x]
    SELECT DATEDIFF(DAY,T0.DOCDATE,T0.DOCDUEDATE)-
    (SELECT COUNT(STRDATE) FROM HLD1 WHERE STRDATE >= T0.DOCDATE AND STRDATE <= T0.DOCDUEDATE)
    FROM OINV T0
    WHERE T0.DOCNUM = xxx
    Best Wishes
    Suda

  • Search between Two date Error

    Hi,
    i have create report using to table i have take search option in that report now i want to display report between two dates
    How to put Between Date Quary in search option in where Clause .
    My code is
    select      CRM_SALES_DEALs.id,
             "CRM_SALES_CUSTOMERS"."CUSTOMER_NAME" as "CUSTOMER_NAME",
          "CRM_SALES_SALESREPS"."REP_LAST_NAME"||', '||
          "CRM_SALES_SALESREPS"."REP_FIRST_NAME" as "REP_NAME",
          "CRM_SALES_DEALS"."DEAL_NAME" as "DEAL_NAME",
          "CRM_SALES_DEALS"."EMAIL" as "EMAIL",
          "CRM_SALES_DEALS"."DEAL_CLOSE_DATE" as "DEAL_CLOSE_DATE",
          "CRM_SALES_DEALS"."DEAL_AMOUNT" as "DEAL_AMOUNT",
          "CRM_SALES_DEALS"."DEAL_PROBABILITY" as "DEAL_PROBABILITY",
          "CRM_SALES_DEAL_STATUS_CODES"."STATUS_CODE" as "STATUS_CODE" ,
             "CRM_SALES_DEALS"."DATE_OF_QUARY" as "DATE_OF_QUARY",
             "CRM_SALES_DEALS"."DEAL_SOURCE" as "DEAL_SOURCE",
             "CRM_SALES_DEALS"."DEAL_AMOUNT" *
             "CRM_SALES_DEALS"."DEAL_PROBABILITY" / 100 weighted_forecast,
    (select count(*) from CRM_SALES_DEAL_products where deal_id = "CRM_SALES_DEALS".id) products,
    nvl("CRM_SALES_DEALS".updated_on,"CRM_SALES_DEALS".created_on) last_changed,
    t.territory_name,
    CRM_SALES_DEALS.qtr, "CRM_SALES_DEALS"."CONTACT_NAME" as "CONTACT_NAME",
    "CRM_SALES_DEALS"."ACTIVE_FLAG" as "ACTIVE_FLAG"
    from     
    "CRM_SALES_SALESREPS",
    "CRM_SALES_DEAL_STATUS_CODES" ,
    "CRM_SALES_CUSTOMERS",
    "CRM_SALES_DEALS",
    CRM_SALES_territories t
    where  
    CRM_SALES_customers.customer_territory_id = t.id(+) and
    "CRM_SALES_DEALS"."CUSTOMER_ID"="CRM_SALES_CUSTOMERS"."ID"(+)
    and      "CRM_SALES_DEALS"."DEAL_STATUS_CODE_ID"="CRM_SALES_DEAL_STATUS_CODES"."ID"(+)
    and      "CRM_SALES_DEALS"."SALESREP_ID_01"="CRM_SALES_SALESREPS"."ID"(+) and "CRM_SALES_DEALS"."ACTIVE_FLAG" ='Y' and (:p1_find is null or instr(upper("CRM_SALES_CUSTOMERS"."CUSTOMER_NAME"),upper(:p1_find))>0 or instr(upper("CRM_SALES_DEALS"."DEAL_NAME"),upper(:p1_find))>0 or
    instr(upper("CRM_SALES_SALESREPS"."REP_FIRST_NAME"||' '||"CRM_SALES_SALESREPS"."REP_LAST_NAME"),upper(:p1_find))>0)
    and
    (nvl(:P1_TERRITORY,0) = 0 or t.id= :P1_TERRITORY)
    and
    (nvl(:P1_ACCOUNT,0) = 0 or "CRM_SALES_CUSTOMERS".id = :P1_ACCOUNT)
    and
    (nvl(:P1_QUARTER,'0') = '0' or CRM_SALES_deals.qtr = :P1_QUARTER)
    and
    *("CRM_SALES_DEALS".created_on between :P1_CREATE_DATE and :P1_END_DATE ) >0 and*                                          *Here I have put Quary*
    instr(upper("CRM_SALES_DEALS"."CREATED_ON"),upper(nvl(:P1_CREATE_DATE,"CRM_SALES_DEALS"."CREATED_ON"))) > 0
    and
    nvl(DEAL_PROBABILITY,10) between nvl(:P1_MINIMUM_PROBABILITY,0) and nvl(:P1_MAXIMUM_PROBABILITY,100) AND
    (nvl(:P1_LEAD_SOURCE,'0') = '0' or CRM_SALES_DEALS.DEAL_SOURCE = :P1_LEAD_SOURCE)Show me Error Command not Properly Ended
    How can i search Between two date In Search option.
    Thanks

    I'm guessing that this is Jay???
    Please heed my numerous previous comments regarding formatting and those horrible full table aliases and upper case, double quoted names... Grrr...
    Anyway, try this...
    SELECT   CRM_SALES_DEALs.id,
             CRM_SALES_CUSTOMERS.CUSTOMER_NAME AS CUSTOMER_NAME,
                CRM_SALES_SALESREPS.REP_LAST_NAME
             || ', '
             || CRM_SALES_SALESREPS.REP_FIRST_NAME
                AS REP_NAME,
             CRM_SALES_DEALS.DEAL_NAME AS DEAL_NAME,
             CRM_SALES_DEALS.EMAIL AS EMAIL,
             CRM_SALES_DEALS.DEAL_CLOSE_DATE AS DEAL_CLOSE_DATE,
             CRM_SALES_DEALS.DEAL_AMOUNT AS DEAL_AMOUNT,
             CRM_SALES_DEALS.DEAL_PROBABILITY AS DEAL_PROBABILITY,
             CRM_SALES_DEAL_STATUS_CODES.STATUS_CODE AS STATUS_CODE,
             CRM_SALES_DEALS.DATE_OF_QUARY AS DATE_OF_QUARY,
             CRM_SALES_DEALS.DEAL_SOURCE AS DEAL_SOURCE,
             CRM_SALES_DEALS.DEAL_AMOUNT * CRM_SALES_DEALS.DEAL_PROBABILITY / 100
                weighted_forecast,
             (SELECT   COUNT ( * )
                FROM   CRM_SALES_DEAL_products
               WHERE   deal_id = CRM_SALES_DEALS.id)
                products,
             NVL (CRM_SALES_DEALS.updated_on, CRM_SALES_DEALS.created_on)
                last_changed,
             t.territory_name,
             CRM_SALES_DEALS.qtr,
             CRM_SALES_DEALS.CONTACT_NAME AS CONTACT_NAME,
             CRM_SALES_DEALS.ACTIVE_FLAG AS ACTIVE_FLAG
      FROM   CRM_SALES_SALESREPS,
             CRM_SALES_DEAL_STATUS_CODES,
             CRM_SALES_CUSTOMERS,
             CRM_SALES_DEALS,
             CRM_SALES_territories t
    WHERE   CRM_SALES_customers.customer_territory_id = t.id(+)
             AND CRM_SALES_DEALS.CUSTOMER_ID = CRM_SALES_CUSTOMERS.ID(+)
             AND CRM_SALES_DEALS.DEAL_STATUS_CODE_ID =
                   CRM_SALES_DEAL_STATUS_CODES.ID(+)
             AND CRM_SALES_DEALS.SALESREP_ID_01 = CRM_SALES_SALESREPS.ID(+)
             AND CRM_SALES_DEALS.ACTIVE_FLAG = 'Y'
             AND (:p1_find IS NULL
                  OR INSTR (UPPER (CRM_SALES_CUSTOMERS.CUSTOMER_NAME),
                            UPPER (:p1_find)) > 0
                  OR INSTR (UPPER (CRM_SALES_DEALS.DEAL_NAME), UPPER (:p1_find)) >
                       0
                  OR INSTR (
                       UPPER(   CRM_SALES_SALESREPS.REP_FIRST_NAME
                             || ' '
                             || CRM_SALES_SALESREPS.REP_LAST_NAME),
                       UPPER (:p1_find)
                    ) > 0)
             AND (NVL (:P1_TERRITORY, 0) = 0 OR t.id = :P1_TERRITORY)
             AND (NVL (:P1_ACCOUNT, 0) = 0
                  OR CRM_SALES_CUSTOMERS.id = :P1_ACCOUNT)
             AND (NVL (:P1_QUARTER, '0') = '0'
                  OR CRM_SALES_deals.qtr = :P1_QUARTER)
             AND CRM_SALES_DEALS.created_on BETWEEN :P1_CREATE_DATE
                                                 AND  :P1_END_DATE
             AND INSTR (
                   UPPER (CRM_SALES_DEALS.CREATED_ON),
                   UPPER (NVL (:P1_CREATE_DATE, CRM_SALES_DEALS.CREATED_ON))
                ) > 0
             AND NVL (DEAL_PROBABILITY, 10) BETWEEN NVL (:P1_MINIMUM_PROBABILITY,
                                                         0)
                                                AND  NVL (
                                                        :P1_MAXIMUM_PROBABILITY,
                                                        100
             AND (NVL (:P1_LEAD_SOURCE, '0') = '0'
                  OR CRM_SALES_DEALS.DEAL_SOURCE = :P1_LEAD_SOURCE)Cheers
    Ben

  • How to caluclate tat between two dates of one timestamp field

    Hi,
    could some one help how to caluclate days between two dates of single timestamp filed and with this
    query
    Select * from m_activity_transaction where actn_opp_id in (
    Select actn_opp_id from m_activity_transaction where ACTN_ACTV_ID = 218
    Group by actn_opp_id
    having count(*) > 1 ) and ACTN_ACTV_ID = 218
    order by actn_performed_on
    iam getting output is
    ACTN_ID ACTN_OPP_ID ACTN_PERFORMED_ON
    319415 95831 27-JAN-12 11.06.20.000000 AM
    315249 95831 08-FEB-12 05.32.54.000000 PM
    301927 103509 20-DEC-11 04.01.43.000000 PM
    301458 103509 19-DEC-11 04.51.03.000000 PM
    294841 115840 10-JAN-12 03.20.12.000000 PM
    312062 115840 11-JAN-12 05.17.06.000000 PM
    and i nedd to caluclate no.of days between two dates like 27-JAN-12 11.06.20.000000 AM and 08-FEB-12 05.32.54.000000 PM where actn_id is unique AND ACTN_OPP_ID IS NOT UNIQUE.
    Thanks in Advance,
    vvr.

    This way?
    with data as
    select 315249 a, 95831 b, to_timestamp('27-JAN-12 11.06.20.000000 AM', 'DD-MON-RR HH.MI.SS.FF6 AM') dt from dual union all
    select 319415, 95831, to_timestamp('08-FEB-12 05.32.54.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 301927, 103509 , to_timestamp('20-DEC-11 04.51.03.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 301458 , 103509 , to_timestamp('19-DEC-11 04.01.43.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 363810 , 144656 , to_timestamp('27-JUN-12 12.43.28.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 363500 , 144656 , to_timestamp('26-JUN-12 11.41.50.000000 AM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 363354 , 144656 , to_timestamp('25-JUN-12 12.41.13.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual
    select a, b, diff
      from (
            select a, b, extract( day from (dt - lag(dt) over (partition by b order by dt, a)) ) diff
              from data
           ) tab
    where tab.diff is not null;
    A                      B                      DIFF                  
    319415                 95831                  12                    
    301927                 103509                 1                     
    363500                 144656                 0                     
    363810                 144656                 1

  • Calculate business day between two dates

    Hi Guys
    I need the count of business days between two  dates
    Date1, Date2 i need the count only business day (exclude sartuday&sunday)
    If date1 is null or nothing i need to pass 0
    If date2 is null or nothing i need to pass 0
    help on this

    Hi,
    To achive this within SSRS, go to the report code window and add the below
    Function getBusinessDaysCount(ByVal tFrom As Date, ByVal tTo As Date) As Integer
    Dim tCount As Integer
    Dim tProcessDate As Date = tFrom
    For x as Integer= 1 To DateDiff(DateInterval.Day, tFrom, tTo) + 1
    If Not (tProcessDate.DayOfWeek = DayOfWeek.Saturday Or tProcessDate.DayOfWeek = DayOfWeek.Sunday) Then
    tCount = tCount + 1
    End If
    tProcessDate = DateAdd(DateInterval.Day, 1, tProcessDate)
    Next
    Return tCount
    End Function
    In the textbox where you need to display the value, add the below expression
    =Code.getBusinessDaysCount(parameters!StartDate.Value,parameters!EndDate.Value)
    It is assumed the you want to pass the two days from parameters named Startdate and EndDate. If not, modify the expression with required values.
    Regards
    Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful. BH

Maybe you are looking for

  • Mini-DVI to Video Adapter No Longer Compatible

    This is an infuriating subject for me. I had a 2007 2.0Ghz Intel Core 2 Duo White Macbook. On a daily basis i used it with my widescreen TV. I am not made of money, so it is an old tube screen that requires a composite connection. When that macbook d

  • Mouse gestures enabled by default???

    Hey I'm getting kinda annoyed when I move my mouse the wrong way and firefox goes to the last page I visited. Now I have no idea how this mouse gesture got there, but I'd like to deactivate it. Its not a firefox gesture as far as I can tell and I nev

  • Track ball won't rotate

    Hi, Can anyone help me with this problem with the tracj ball on the device?  I can make it go up and down(scroll through a list) but not sideways--any suggestions? Thanks!

  • Aggregator Problems

    I have three swfs/projects that are daisy chained and also put into the aggregator. The aggregated file is here. When it gets to the end of one swf and starts the next, instead of showing the next swf correctly, it plays the audio only for a few seco

  • Forms blank when sent from IPAD.

    I've created a fillable form on my PC.  All of the recipients use IPAD.  When they fill out the form and email it back to me it is blank.  When I do it from my PC it works fine.  Can someone help me figure out why???  We downloaded Adobe Reader to th