Generating Dates Between Date Range

Hi,
I have a table with test_id, a_id, start_date, end_date like the below.
test_id a_id start_date end_Date
861 2123 05-Dec-2009 10-Dec-2009
861 2124 06-Dec-2009 09-Dec-2009
864 2123 08-Dec-2009 10-Dec-2009
864 2124 07-Dec-2009 11-Dec-2009
I need to generate dates between the start_date and end_date like the below. Kindly help.
test_id a_id start_date end_Date tdate
861 2123 05-Dec-2009 10-Dec-2009 05-Dec-2009
861 2123 05-Dec-2009 10-Dec-2009 06-Dec-2009
861 2123 05-Dec-2009 10-Dec-2009 07-Dec-2009
861 2123 05-Dec-2009 10-Dec-2009 08-Dec-2009
861 2123 05-Dec-2009 10-Dec-2009 09-Dec-2009
861 2123 05-Dec-2009 10-Dec-2009 10-Dec-2009
861 2124 06-Dec-2009 09-Dec-2009 06-Dec-2009
861 2124 06-Dec-2009 09-Dec-2009 07-Dec-2009
861 2124 06-Dec-2009 09-Dec-2009 08-Dec-2009
861 2124 06-Dec-2009 09-Dec-2009 09-Dec-2009
864 2123 08-Dec-2009 10-Dec-2009 08-Dec-2009
864 2123 08-Dec-2009 10-Dec-2009 09-Dec-2009
864 2123 08-Dec-2009 10-Dec-2009 10-Dec-2009
864 2124 07-Dec-2009 11-Dec-2009 07-Dec-2009
864 2124 07-Dec-2009 11-Dec-2009 08-Dec-2009
864 2124 07-Dec-2009 11-Dec-2009 09-Dec-2009
864 2124 07-Dec-2009 11-Dec-2009 10-Dec-2009
864 2124 07-Dec-2009 11-Dec-2009 11-Dec-2009
Please reply at the earliest. Its very urgent. Thanks in advance.
Regards,
Gayathri Devi

with t
as
select 861 test_id, 2123 a_id, to_date('05-Dec-2009','dd-mon-yyyy') start_date, to_date('10-Dec-2009','dd-mon-yyyy') end_date from dual union all
select 861, 2124, to_date('06-Dec-2009','dd-mon-yyyy'), to_date('09-Dec-2009','dd-mon-yyyy') from dual union all
select 864, 2123, to_date('08-Dec-2009','dd-mon-yyyy'), to_date('10-Dec-2009','dd-mon-yyyy') from dual union all
select 864, 2124, to_date('07-Dec-2009','dd-mon-yyyy'), to_date('11-Dec-2009','dd-mon-yyyy') from dual
select test_id, a_id, start_date, end_date, start_date+no-1 dt
  from t
  cross join
select level no
  from dual
connect by level <= (select max(end_date-start_date+1) from t)
where case when start_date+no-1 > end_date then null else start_date+no-1 end is not null
order by 1,2,5

Similar Messages

  • List Months between a date range

    Hi, I'm trying to list the months between a given date range in an ABAP report to generate a MIS report(ALV).. Say I have 2 date ranges, 01.01.2006 to 01.04.2006.. I want to list
    Jan 2006
    Feb 2006
    Mar 2006
    Apr 2006.. Any FM in SAP to get this OP..

    hi vivek,
    use this function module to get months beween two dates
    1. MONTHS_BETWEEN_TWO_DATES   or
    2. MONTHS_BETWEEN_TWO_DATES_NEW
    please reward the point if you are satisfied with answer
    thanks,
    john.

  • Need help to join two tables using three joins, one of which is a (between) date range.

    I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
    the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
    ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
    [ABCTABLE]
    ABCORDER
    ABCPART
    ABCSERIAL
    ABCDATE
    [ZYXTABLE]
    XYZORDER
    XYZPART
    XYZSERIAL
    XYZDATE1
    XYZDATE2

    Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
    on this computer. There are no "Null" fields in either of the tables. 
    This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
    [MSORDR]
    MSORDER
    MSPART
    MSSERIAL
    MSOPNDATE
    11111111
    4444444
    55555
    2/4/2015
    22222222
    6666666
    11111
    1/6/2015
    33333333
    6666666
    11111
    3/5/2015
    This table has one order for every part number and every serial number.
    [GLORDR]
    GLORDER
    GLPART
    GLSERIAL
    GLSTARTDATE
    GLENDDATE
    ABC11111
    444444
    55555
    1/2/2015
    4/4/2015
    ABC22222
    666666
    11111
    1/5/2015
    4/10/2015
    AAA11111
    555555
    22222
    3/2/2015
    4/10/2015
    Post Query table
    GLORDER
    MSORDER
    GLSTARTDATE
    GLENDDATE
    MSOPNDATE
    ABC11111
    11111111
    1/2/2015
    4/4/2015
    2/4/2015
    ABC22222
    22222222
    1/5/2015
    4/10/2015
    1/6/2015
    ABC22222
    33333333
    1/5/2015
    4/10/2015
    3/5/2015
    This is the SQL minus the between date join.
    SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
    FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART);

  • Using analytical function to calculate concurrency between date range

    Folks,
    I'm trying to use analytical functions to come up with a query that gives me the
    concurrency of jobs executing between a date range.
    For example:
    JOB100 - started at 9AM - stopped at 11AM
    JOB200 - started at 10AM - stopped at 3PM
    JOB300 - started at 12PM - stopped at 2PM
    The query would tell me that JOB1 ran with a concurrency of 2 because JOB1 and JOB2
    were running started and finished within the same time. JOB2 ran with the concurrency
    of 3 because all jobs ran within its start and stop time. The output would look like this.
    JOB START STOP CONCURRENCY
    === ==== ==== =========
    100 9AM 11AM 2
    200 10AM 3PM 3
    300 12PM 2PM 2
    I've been looking at this post, and this one if very similar...
    Analytic functions using window date range
    Here is the sample data..
    CREATE TABLE TEST_JOB
    ( jobid NUMBER,
    created_time DATE,
    start_time DATE,
    stop_time DATE
    insert into TEST_JOB values (100, sysdate -1, to_date('05/04/08 09:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 11:00:00','MM/DD/YY hh24:mi:ss'));
    insert into TEST_JOB values (200, sysdate -1, to_date('05/04/08 10:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 13:00:00','MM/DD/YY hh24:mi:ss'));
    insert into TEST_JOB values (300, sysdate -1, to_date('05/04/08 12:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 14:00:00','MM/DD/YY hh24:mi:ss'));
    select * from test_job;
    JOBID|CREATED_TIME |START_TIME |STOP_TIME
    ----------|--------------|--------------|--------------
    100|05/04/08 09:28|05/04/08 09:00|05/04/08 11:00
    200|05/04/08 09:28|05/04/08 10:00|05/04/08 13:00
    300|05/04/08 09:28|05/04/08 12:00|05/04/08 14:00
    Any help with this query would be greatly appreciated.
    thanks.
    -peter

    after some checking the model rule wasn't working exactly as expected.
    I believe it's working right now. I'm posting a self-contained example for completeness sake.I use 2 functions to convert back and forth between epoch unix timestamps, so
    I'll post them here as well.
    Like I said I think this works okay, but any feedback is always appreciated.
    -peter
    CREATE OR REPLACE FUNCTION date_to_epoch(p_dateval IN DATE)
    RETURN NUMBER
    AS
    BEGIN
    return (p_dateval - to_date('01/01/1970','MM/DD/YYYY')) * (24 * 3600);
    END;
    CREATE OR REPLACE FUNCTION epoch_to_date (p_epochval IN NUMBER DEFAULT 0)
    RETURN DATE
    AS
    BEGIN
    return to_date('01/01/1970','MM/DD/YYYY') + (( p_epochval) / (24 * 3600));
    END;
    DROP TABLE TEST_MODEL3 purge;
    CREATE TABLE TEST_MODEL3
    ( jobid NUMBER,
    start_time NUMBER,
    end_time NUMBER);
    insert into TEST_MODEL3
    VALUES (300,date_to_epoch(to_date('05/07/2008 10:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 19:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (200,date_to_epoch(to_date('05/07/2008 09:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 12:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (400,date_to_epoch(to_date('05/07/2008 10:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 14:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (500,date_to_epoch(to_date('05/07/2008 11:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 16:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (600,date_to_epoch(to_date('05/07/2008 15:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 22:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (100,date_to_epoch(to_date('05/07/2008 09:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 23:00','MM/DD/YYYY hh24:mi')));
    commit;
    SELECT jobid,
    epoch_to_date(start_time)start_time,
    epoch_to_date(end_time)end_time,
    n concurrency
    FROM TEST_MODEL3
    MODEL
    DIMENSION BY (start_time,end_time)
    MEASURES (jobid,0 n)
    (n[any,any]=
    count(*)[start_time<= cv(start_time),end_time>=cv(start_time)]+
    count(*)[start_time > cv(start_time) and start_time <= cv(end_time), end_time >= cv(start_time)]
    ORDER BY start_time;
    The results look like this:
    JOBID|START_TIME|END_TIME |CONCURRENCY
    ----------|---------------|--------------|-------------------
    100|05/07/08 09:00|05/07/08 23:00| 6
    200|05/07/08 09:00|05/07/08 12:00| 5
    300|05/07/08 10:00|05/07/08 19:00| 6
    400|05/07/08 10:00|05/07/08 14:00| 5
    500|05/07/08 11:00|05/07/08 16:00| 6
    600|05/07/08 15:00|05/07/08 22:00| 4

  • Sum an amount between a certain date range

    Hello,
    I am working out a home budget and want to know how to calculate what is due this month.
    I have two columns - "Amount" and "Due Date". Some content for an example is:
    Amount,Due Date
    20,15/05/2009
    300,16/05/2009
    40,1/06/2009
    What I want is a formula which will sum the total amount of items due within this months' date range. If the date range could be as automatic as "This Month" that would be great otherwise I would say IF "Due Date" between 1/05/2009 and 31/5/2009.
    Is this possible?

    In column D, the formula is:
    =YEAR(C)*100+MONTH(C)
    In B8 and in B9 the formula is:
    =SUMIF(D,YEAR(A)*100+MONTH(A),B)
    Yvan KOENIG (from FRANCE jeudi 14 mai 2009 15:30:56)

  • Extracting a count of distinct values between two date ranges over months

    Hi All,
    I am having a bit of difficulty in figuring out the query to build a list of active campaigns over a date range.
    i.e. I have a table with campaign IDs and their start and end date details like this
    Campaign_id     Start_date     End_date
            10001     1-Jun-09     31-May-11
            10002     1-Jun-09     23-Jun-11
            30041     21-Aug-09     31-Dec-09
            20005     3-Jun-10     31-May-11
            90021     21-Nov-09     30-Nov-10
            54000     1-Jun-11     1-Dec-12
            35600     1-Mar-10     31-Mar-12 What the above data means is, for eg. the campaign 10001 is active from 1-Jun-09 to 31-May-11 i.e. for 24 months (inclusive of the month Jun-09 and May-11)
    What I need to figure out is the counts of active campaigns between a date range and display that active count at a month level (for e.g. lets say we want to see all the campaigns that were active
    between the date range '01-JUN-2007' and '30-APR-2012' ). So the partial output would be as seen below. The list would continue till december-2012
    Month    Year    Count of active campaigns
    Jan    2009    0
    Feb    2009    0
    Mar    2009    0
    Apr    2009    0
    May    2009    0
    Jun    2009    2
    Jul    2009    2
    Aug    2009    3
    Sep    2009    3
    Oct    2009    3
    Nov    2009    4
    Dec    2009    4
    Jan    2010    3
    Feb    2010    3
    Mar    2010    4
    Apr    2010    4
    Dec    2012    1 Could anybody please help me with the right query for this.
    Thanks a lot for help
    Regards
    Goldi

    set pagesize 40
    with tab as
                    select 1 id, sysdate -100 start_date, sysdate end_date from dual
                    union
                    select 1 id, sysdate -200 start_date, sysdate -150 end_date from dual
                    union
                    select 1 id, sysdate -600 start_date, sysdate - 400 end_date from dual
                    union
                    select 1 id, sysdate -300 start_date, sysdate - 150 end_date from dual
                    union
                    select 2 id, sysdate -100 start_date, sysdate-50 end_date from dual
          year_tab as
                        select
                                 add_months(min_date, level -1) m
                        from
                                select min(trunc(start_date,'YYYY')) min_date, add_months(max(trunc(end_date,'YYYY')), 12) max_date
                                from tab
                        connect by level <= months_between(max_date, min_date)
    select to_char(m,'YYYY') year_,
             to_char(m,'Month') month_,
             nvl(act, 0) act
    from   year_tab,
                select m date_,count(*)  act
                from tab, year_tab
                where m between trunc(start_date,'MM') and trunc(end_date,'MM')
                group by m
                ) month_tab
    where m = date_(+)
    order by m;
    YEAR_ MONTH_           ACT
    2010  January            0
    2010  February           0
    2010  March              0
    2010  April              0
    2010  May                0
    2010  June               0
    2010  July               0
    2010  August             0
    2010  September          1
    2010  October            1
    2010  November           1
    2010  December           1
    2011  January            1
    2011  February           1
    2011  March              1
    2011  April              0
    2011  May                0
    2011  June               0
    2011  July               1
    2011  August             1
    2011  September          1
    2011  October            2
    2011  November           2
    2011  December           2
    2012  January            2
    2012  February           2
    2012  March              2
    2012  April              1
    2012  May                1
    2012  June               0
    2012  July               0
    2012  August             0
    2012  September          0
    2012  October            0
    2012  November           0
    2012  December           0
    36 rows selected.

  • Group by week between date range

    Hi,
    i'm having a table for documents. The documents are received from diffeent dates. I've to calculate number of documents received on weekly basis.
    I need an sql to count the number of documents between two given dates grouping by weekly.
    My week starts on Sunday and ends with Saturday.
    I've tried group by with to_char(documentdate,'IW') , but this will take Monday to Sunday as a week & the incomlete weeks i'm not able to calculate. ie : in the below output the date range 1/28/2007 - 1/31/2007 is not a complete week . ( ie saturday to wednesday)
    I need out put should be like this for Date Range: 12/31/2006 to 1/31/2007
    week               count of documents
    12/31/2006 - 1/6/2007 10
    1/7/2007 - 1/13/2007     40
    1/14/2007 - 1/20/2007     30
    1/21/2007 - 1/27/2007     20
    1/28/2007 - 1/31/2007 10
    Please help me to get this.....
    (columns in documents table is documentid and documentdate)

    your're very close with IW. you just need to shift the data to get it to fall within the correct range. btw, you don't need julian dates. it's overkill
    trunc(date+1,'IW') will push the date into the correct week range (IW will put sunday one week earlier than you want, so push it ahead a day before truncating).
    then subtract 1 day from the result to get it to display with sunday's date instead of monday
    trunc(mydate+1, 'IW')-1
    and the week end date is simply trunc(mydate+1, 'IW')_5
    select mydate, to_char(mydate,'Dy') dy,
    trunc(mydate+1,'IW')-1 wk_Start,
    trunc(mydate+1,'IW')+5 wk_end
    from (select sysdate-rownum mydate from dual connect by level < 20)
    order by 1

  • Oracle 10g - Problem with Date Ranges using Between

    I am keeping track of patients who have not been contacted during a date range. if a nurse adds an event or note and the note is type 1,3,4 then this is a contact. The following works but if the event or note was made on the same day as the report is run, the current contact is not printed. Any help to improve the query and identify the problem would be appreciated. Also, if you add '1' to' n.created_date_time BETWEEN '10-Jan-2010' AND TRUNC(SYSDATE)' so it is ' n.created_date_time BETWEEN '10-Jan-2010' AND TRUNC(SYSDATE) + 1'. It works. What is wrong?
    SELECT upper(symptom_text),
      COUNT(UNIQUE(c.patient_id)) ,
      COUNT(UNIQUE(
      CASE
        WHEN e.eventdate BETWEEN '10-Jan-2010' AND TRUNC(SYSDATE)
        OR (n.created_date_time BETWEEN '10-Jan-2010' AND TRUNC(SYSDATE)
        AND n.note_type_id                                             IN (1,3,4))
        THEN c.patient_id
        ELSE 0
      END)) - 1
    FROM patient c,
      cust_info ci,
      event e,
      note n
    WHERE c.physician_id = 74
    AND c.patient_id      = ci.patient_id
    AND ci.info_type_id    = 32
    AND ci.symptom_text      IS NOT NULL
    AND c.patient_id      = e.patient_id(+)
    AND c.patient_id      = n.pk_id(+)
    AND n.table_name(+)    = 'patient'
    GROUP BY upper(symptom_text)
    ORDER BY DECODE(upper(symptom_text), 'A+', 1, 'A', 2, 'B', 3, 'C', 4, 'D', 5, 99)I suspect the end date is not inclusive. Fields are Date data types. Thanks for any help.

    Hi,
    achtung wrote:
    Understood. Frank was correct. Do you mean about the dates? Is that issue solved now?
    It would help a lot if you posted some sample data (CREATE TABLE and INSERT statements) and the results you want from that data. Simplify as much as possible. For example, if everything involving the e and n tables is working correctly, forget about them for now. Post a question that only invloves the c and ci tables.
    But, additionally, when a record in the cust_info doesn't exist my contact count is inaccurate. How can you explain this conceptually. I understand the query path is checking for this record due to the predicate. Perhaps the query should be redesigned. Thanks for your input!Again, you can see the results, and you know what they should be. Nobody else has that information. Please post some sample data and the results you want from that data.
    In your earlier message you said
    Could there be a problem if a record does not exist in the ci table?The condition:
    AND ci.symptom_text IS NOT NULL
    filters for this right? Maybe this could be part of the problem. why I'm not seeing records when a note is added to a patient's doc. How would this be technically be explained? You're doing a inner join between c and ci:
        AND c.patient_id      = ci.patient_id
        AND ci.info_type_id   = 32
        AND ci.symptom_text   IS NOT NULL ...Rows from c will be included only if there is a row in ci with the same patiend_id: even more, that matching row in ci must also have info_type_id=32 in a non-NULL symptom_text, otherwise, the row from c will be ignored.
    If you want rows from c to be included even if there is no matching row in ci, then do an outer join, like you're already doing with the e and n tables:
      WHERE c.physician_id = 74
        AND c.patient_id         = ci.patient_id (+)
        AND ci.info_type_id (+)  = 32
        AND ci.symptom_text (+)  IS NOT NULL
        AND c.patient_id         = e.patient_id(+)
        AND c.patient_id         = n.pk_id(+)
        AND n.table_name(+)      = 'patient'

  • How to use SQL to display Datethat falls between the date range

    Hi,
    I'm figuring out how do i use SQL to select data
    that falls between the date range stated
    (for eg. 19/02/1955 to 19/02/2003)
    I've tried :
    sql="Select * From StudentRecords WHERE DOB BETWEEN #" jTextField21.getText() "#" +" And " +"#" +jTextField22.getText;
    Using BETWEEN statment , but Between Statement isn't doing what i want..
    even those out of range are displayed... any ideas how??
    Thank yOU in advance!

    oracle:
    sql = "Select * From StudentRecords WHERE DOB between TO_DATE('07/04/2003','dd/mm/yyyy') and TO_DATE('08/04/2003','dd/mm/yyyy')";

  • Function module to calculate no of days between two date ranges

    hi experts,
    can some one please suggest a function module that can calculate no of days between specified date range.
    for example : if i enter date range between 26.02.2011 to 20.05.2011, then it should calculate no of days between these dates.
    Moderator message : Basic date questions not allowed. Read forum rules before posting. Thread locked.
    Edited by: Vinod Kumar on May 25, 2011 10:57 AM

    Hi,
    Please search SDN.. there are lots of posts for teh same.
    [http://wiki.sdn.sap.com/wiki/display/ABAP/FunctionModulerelatedonDate+calculations]

  • Saturday's between date range

    Hi All,
                I need to findout the number of satuday's between the given date range.
    Please tell me if there are any function modules or methods to calculate this.
    Regards
    Suprith

    Hi Suprith,
    Please refer the below Code.
    CALL FUNCTION 'DAY_ATTRIBUTES_GET'
    EXPORTING
    *   FACTORY_CALENDAR                 = ' '
    *   HOLIDAY_CALENDAR                 = ' '
       DATE_FROM                        = From_Date
       DATE_TO                          = To_Date
       LANGUAGE                         = SY-LANGU
    *   NON_ISO                          = ' '
    * IMPORTING
    *   YEAR_OF_VALID_FROM               =
    *   YEAR_OF_VALID_TO                 =
    *   RETURNCODE                       =
      TABLES
        day_attributes                   = it_day_attri
    * EXCEPTIONS
    *   FACTORY_CALENDAR_NOT_FOUND       = 1
    *   HOLIDAY_CALENDAR_NOT_FOUND       = 2
    *   DATE_HAS_INVALID_FORMAT          = 3
    *   DATE_INCONSISTENCY               = 4
    *   OTHERS                           = 5
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    in the Export internal table it_day_attri  you will get all the dates and its respective days. if you delete the records other than Saturday , the number of entries will be needed count of saturday.
    delete it_day_attri where WEEKDAY  <> '6'.
    DESCRIBE TABLE it_day_attri LINES Count.
    note  :  weekday day number ( Saturday = 6 may vary based on factory calendar )
    Edited by: Prasath Arivazhagan on Apr 8, 2010 1:07 PM

  • How to count the days between Date Range using OO ABAP?

    hi experts,
            i want to count the days between Date Range using OO ABAP for that  which class and method  can i use?.
    Thanks,
    Mahesh.

    Not sure I understand the requirement for it to be OO, but you could always write your own (i.e. use this):
    REPORT zz_date_diff.
    CLASS date_diff DEFINITION.
      PUBLIC SECTION.
        METHODS diff IMPORTING     i_date_fm TYPE d
                                   i_date_to TYPE d
                     EXPORTING     e_days    TYPE i.
    ENDCLASS."
    CLASS date_diff IMPLEMENTATION.
      METHOD diff.
        e_days = i_date_to - i_date_fm.
      ENDMETHOD."
    ENDCLASS."
    DATA: g_ref TYPE REF TO date_diff,
          g_days  TYPE i,
          g_date_fm  TYPE d VALUE '20080101',
          g_date_to  TYPE d VALUE '20090101'.
    START-OF-SELECTION.
      CREATE OBJECT g_ref.
      CALL METHOD g_ref->diff
        EXPORTING
          i_date_fm = g_date_fm
          i_date_to = g_date_to
        IMPORTING
          e_days    = g_days.
      WRITE g_days.

  • List in between date range

    i'm having data stored as follows
    DEPOT_CODE EMP_ID ACTIVE_FROM ACTIVE_TO
    400 68955 01-JAN-08 31-JAN-09
    400 68962 01-JAN-08 20-JAN-08
    400 68999 01-JAN-08
    400 689600 01-JAN-08
    400 684530 01-JAN-08
    I wanted to list all the records active in between given date range even though active_to is null
    i.e if i give 10/01/2008 to 02/02/2008
    i want to display all the records which is shown in above
    Thanking you

    Lakmal, I wouldn't take advise from Bhaskar on this one, as he clearly does
    not know how to work with dates, and also does not grasp the concept of a
    date range.
    You have a range, and you want to check if it covers (in whole or in part)
    the from-to period, right?
    I changed the data to include a row (first one) not to be output.
    with dummy as (
    select 400 depot_code, 68955 emp_id, to_date('01-JAN-08', 'DD-MON-YY') active_from, 
        to_date('05-JAN-08', 'DD-MON-YY') active_to from dual union all
    select 400 depot_code, 68955 emp_id, to_date('01-JAN-08', 'DD-MON-YY') active_from, 
        null active_to from dual union all 
    select 400 depot_code, 68955 emp_id, to_date('01-JAN-08', 'DD-MON-YY') active_from, 
        to_date('31-JAN-09', 'DD-MON-YY') active_to from dual union all
    select 400 depot_code, 68962 emp_id, to_date('01-JAN-08', 'DD-MON-YY') active_from, 
        to_date('20-JAN-08', 'DD-MON-YY') active_to from dual union all
    select 400 depot_code, 68999 emp_id, to_date('01-JAN-08', 'DD-MON-YY') active_from, 
        null active_to from dual
    select *
    from dummy
    DEPOT_CODE     EMP_ID ACTIVE_FR ACTIVE_TO
           400      68955 01-JAN-08 05-JAN-08
           400      68955 01-JAN-08         
           400      68955 01-JAN-08 31-JAN-09
           400      68962 01-JAN-08 20-JAN-08
           400      68999 01-JAN-08         
    5 rows selected.
    SELECT *
      FROM dummy
    WHERE NVL (active_to, TO_DATE ('10-JAN-08', 'DD-MON-YY')) >=
                   TO_DATE ('10-JAN-08', 'DD-MON-YY')
                   AND active_from <= to_date('02-FEB-08', 'DD-MON-YY')
    DEPOT_CODE     EMP_ID ACTIVE_FR ACTIVE_TO
           400      68955 01-JAN-08         
           400      68955 01-JAN-08 31-JAN-09
           400      68962 01-JAN-08 20-JAN-08
           400      68999 01-JAN-08         
    4 rows selected.given that active_from is never null.
    Isn't it as simple as this? The active_to must be after your start_date,
    and the active_from must be before the end....

  • Parameter prompts-  Displaying task details between date range

    Hi all,
    I have created a report ( Crystal reports 2008) which lists task related details( distinct count) by region, customer and work type. I created two parameters to let the users specify the date ranges. Based on the user inputs, the title of the report would be " there are -- tasks between the user specified date ranges//-- and -//".  I am not sure how to go about displaying the title in the format specified.
    It would be great if you guys could give me your suggestions on this.
    Thanks a lot,
    Vinne
    Edited by: Vinnie_uic on Jun 8, 2010 9:32 AM

    Hi, I don't have 2008, but this should still work.
    You can add your text as shown.
    " there are   tasks between the user specified date ranges and  "
    Add your parameters to the report, also add a counter for your tasks.
    then you just drag and drop those into the title.
    When you edit the title it "May" look like this.
    "There are {@Count_of_Tasks}  tasks between the user specified date ranges {?Start_date} and {?End_Date} "
    but it should display as
    "There are 15  tasks between the user specified date ranges 5/20/2010  and 5/17/2010 "
    If that does not work for you, use the & sign, and create your formula like this.
    There are &" "& {@Count_of_Tasks}&" "&  tasks between the user specified date ranges &" "&{?Start_date} and&" "& {?End_Date}
    I hope the formatting is correct for 2008

  • Max date data between the input date range.

    Hi
    I need to get the maximum date data's with in the date range.
    Ex: this is sample date but , total records in DB around 2000.
    NAME DATE Product1 Product2
    aaaa 01/05/2011 5 5
    aaaa 03/05/2011 3 3
    bbbb 04/05/2011 6 6
    bbbb 07/05/2011 2 2
    aaaa 06/05/2011 1 1
    case :1) If the user input date is 01/05/2011 to 05/05/2011
    then the result should be
    aaaa 3 3
    bbbb 6 6
    case :2) If the user input date is 01/05/2011 to 10/05/2011
    then the result should be
    aaaa 1 1
    bbbb 2 2
    so my result is purely based on max date between the input date range.
    how to achieve the result

    Dhiva wrote:
    Hi
    I need to get the maximum date data's with in the date range.
    Ex: this is sample date but , total records in DB around 2000.
    NAME DATE Product1 Product2
    aaaa 01/05/2011 5 5
    aaaa 03/05/2011 3 3
    bbbb 04/05/2011 6 6
    bbbb 07/05/2011 2 2
    aaaa 06/05/2011 1 1
    case :1) If the user input date is 01/05/2011 to 05/05/2011Jan 05 to May 05
    or
    May 01 to May 05
    what date is 07/08/09?

Maybe you are looking for

  • How do i access my icloud account on itunes/

    How do I access my iCloud on my iTunes account?

  • Please bring back an option to Add Scroll Arrows!?

    Mac OS X v10.7 Lion - has removed scrollbars and changed the direction of scrolling to better align with iphones, ipads, etc.  Thankfully, there are options to go back to behavior similar to classic scrolling behavior, with one important exception. 

  • Serious design flaw in iWeb needs fixing fast

    I have been designing websites with various types of software in the past. Always a wysiwyg environment has been amongst my favourites as it shows exactly what you are doing, how it looks and what it's going to be like for the viewer. Now iWeb does a

  • IWork 09 - Auto Generating Headings

    Hi Guys, This is driving me up the wall, I have iWork '09 and in the Paragraph Styles section, when I click Heading 2 it automatically generates a new heading style called Heading 3, all the way up to 9. If I try and delete the heading, the delete bu

  • Report download security

    My users are asking if it is possible in an interactive report to only allow certain users to see and use the download option based on responsiblity. I know I can turn off the feature for the entire report, but is there a way to turn it on/off progra