Date ranges(5 months)

Hi all...
  Iam having one date field in the selection screen....
so when i excuted the program i have to get exact five months back date as low range and current date as high range...
thank you,
Naveen

Hi Naveen
try the following
data : bk_date type sy-datum.
select-options: so_date for sy-datum.
INITIALIZATION.
  call function 'CCM_GO_BACK_MONTHS'
    exporting
      currdate   = sy-datum
      backmonths = 5
    importing
      newdate    = bk_date.
  clear so_date.
  so_date-sign   = 'I'.
  so_date-option = 'BT'.
  so_date-low    = bk_date.
  so_date-high   = sy-datum.
  append so_date.
reward if useful.
Regards
Prabumanoharan

Similar Messages

  • 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.

  • Need work around to split date range into months

    Hi All,
    I have a requirement to split the data range in source table to months.
    here is the source table
    ID Sdate Edate Code
    ===============================
    501 1/4/2009 4/30/2009 AH
    501 5/1/2009 9/30/2009 AB
    502 1/1/2014 5/31/2014 AC
    Here is my target
    ID Sdate Edate Code
    ================================
    501 1/4/2009 1/31/2009 AH
    501 2/1/2009 2/28/2009 AH
    501 3/1/2009 3/31/2009 AH
    501 4/1/2009 4/30/2009 AH
    501 5/1/2009 5/31/2009 AB
    501 6/1/2009 6/30/2009 AB
    501 7/1/2009 7/31/2009 AB
    501 8/1/2009 8/31/2009 AB
    501 9/1/2009 9/30/2009 AB
    502 1/1/2014 1/31/2014 AC
    502 2/1/2014 2/28/2014 AC
    502 3/1/2014 3/31/2014 AC
    502 4/1/2014 4/30/2014 AC
    502 5/1/2014 5/31/2014 AC
    Please provide some input.
    Thanks a lot in advance.

    That means your database is in a different locale than mine. When I select cast(Edate as varchar), I get the date returned in the format 'YYYY-MM-DD'. That's why I use(left(cast(Edate as varchar),4) + right(left(cast(Edate as varchar),7),2) to get it the format 'YYYYMM' before converting it into an integer.
    Your database most probably returns dates in a format like D/MM/YYYY. That's the reason for the error you get. You'll have to select (right(cast(Edate as varchar),4) + left(right(cast(Edate as varchar),7),2) to obtain the same results as I do.
    Alternatively, you can use the convert function to obtain the same results:
         select max(
         cast(left(convert(varchar,Edate,102),4) + right(left(convert(varchar,Edate,102),7),2) as int) + 1 -
         cast(left(convert(varchar,Sdate,102),4) + right(left(convert(varchar,Sdate,102),7),2) as int))
         FROM src_split'
    It's always good practice to test the SQL-statements in your database client first before including them in a DS script.
    Also, I suddenly realise this statement will only return the correct result when your Edate and Sdate are always within the same year. If that's not the case, but the gap between Edate and Sdate is always less than 10 years, change your statement to:
         select max(
         cast(left(convert(varchar,Edate,102),4) + right(left(convert(varchar,Edate,102),7),2) as int) + 1 -
         cast(left(convert(varchar,Sdate,102),4) + right(left(convert(varchar,Sdate,102),7),2) as int)) % 88
         FROM src_split'

  • CONVERT   DATE RANGE INTO MONTHS

    HI FRIENDS,
    ACTUALLY IN MY SELECT-OPTIONS I HAVE USED DATE BETWEEN 03/06/1980  TO 04/12/1980
    BASED ON THIS DATE I HAVE TO CALCULATE NUMBER OF MONTHS.
    WILL THIS BE DONE AUTOMATICALLY OR I NEED TO WRITE ANY CODE FOR CONVERTING THE DATE RANGE INTO NUMBER OF MONTHS.
    REGARDS
    SIRI.

    Hi,
    Use FM's : MONTHS_BETWEEN_TWO_DATES_NEW
               MONTHS_BETWEEN_TWO_DATES
               FIMA_DAYS_AND_MONTHS_AND_YEARS
    Sample code :
    DATA : x_no_months type i.
    DATA : x_stdat like sy-datum,
           x_enddat like sy-datum.
           x_stdat  = s_date-low
           x_enddat = s_date-high
    CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
        EXPORTING
          i_datum_bis = x_stdat
          i_datum_von = x_enddat
        IMPORTING
          e_monate    = x_no_months.
    x_no_months will contain no.of months.
    Regards
    Appana

  • Displaying different sums in the same row based on date ranges

    Say I had a table like this
    DECLARE @t1 TABLE (RowId INT PRIMARY KEY IDENTITY(1,1), BusinessType VARCHAR(100), SalesPerson VARCHAR(100), Category VARCHAR(100), OrderAmount DECIMAL(10,2), OrderDate DATETIME )
    Now I want to get a result that is grouped first by BusinessType, then SalesPerson and include derived columns that are sums based  on different date ranges.
    Month-to-date = from the start of the current month to today
    Month-to-date previous year = from the start of the current month to today 1 year ago
    DECLARE @today DATETIME
    DECLARE @today_prev_year DATETIME
    DECLARE @year_start DATETIME
    DECLARE @year_prev_start DATETIME
    DECLARE @month_start DATETIME
    DECLARE @month_prev_start DATETIME
    SET @today = GETDATE();
    SET @today_prev_year = DATEADD(YEAR,-1,@today)
    SET @year_start = CAST('01/01/' + CAST(DATEPART(YEAR,GETDATE()) AS VARCHAR(10)) AS DATETIME);
    SET @year_prev_start = DATEADD(YEAR,-1,@year_start)
    SET @month_start = DATEADD(month, DATEDIFF(month, 0, @today), 0); --gets the first of the current month
    SET @month_prev_start = DATEADD(YEAR,-1,@month_start); --gets the first of the current month
    SELECT t.BusinessType,t.SalesPerson,t.Category
    SUM(CASE WHEN o.OrderDate > @month_start AND ac.DocumentDate < @today THEN o.OrderAmount ELSE 0 END) AS MTDActualAmount
    SUM(CASE WHEN o.OrderDate > @month_prev_start AND ac.DocumentDate < @today_prev_year THEN o.OrderAmount ELSE 0 END) AS MTDPrevActualAmount
    FROM @t1 t
    Hope this is clear as to what Im trying to do.  Im ultimately going to pull this into an SSRS report, so im wondering if I can do this different SUM values in the report and handle the grouping there.
    Thoughts?

    Based on your example (with a group by added) it should work.
    However, if you incorperated a calendar table (http://social.technet.microsoft.com/wiki/contents/articles/29260.tsql-calendar-functions-and-tables.aspx)
    you could lose all those manually set parameters:
    DECLARE @t1 TABLE (RowId INT PRIMARY KEY IDENTITY(1,1), BusinessType VARCHAR(100), SalesPerson VARCHAR(100), Category VARCHAR(100), OrderAmount DECIMAL(10,2), OrderDate DATETIME, DocumentDate DATETIME)
    INSERT INTO @t1 (BusinessType, SalesPerson, Category, OrderAmount, OrderDate, DocumentDate) VALUES
    ('A','Joe','CatA',10,'2015-01-01','2015-01-01'),('A','Joe','CatB',10,'2015-01-02','2015-01-01'),('A','Joe','CatA',30,'2015-01-03','2015-01-04'),('A','Joe','CatB',40,'2015-01-04','2015-01-01'),('A','Joe','CatA',100,'2015-02-01','2015-02-01'),
    ('A','Joe','CatB',100,'2015-02-02','2015-02-01'),('A','Joe','CatA',300,'2015-02-03','2015-02-04'),('A','Joe','CatB',400,'2015-02-04','2015-02-01'),('A','Bob','CatA',1,'2015-01-01','2015-01-01'),('A','Bob','CatB',1,'2015-01-02','2015-01-01'),
    ('A','Bob','CatA',3,'2015-01-03','2015-01-04'),('A','Bob','CatB',4,'2015-01-04','2015-01-01'),('A','Bob','CatA',10,'2015-02-01','2015-02-01'),('A','Bob','CatB',10,'2015-02-02','2015-02-01'),('A','Bob','CatA',30,'2015-02-03','2015-02-04'),
    ('A','Bob','CatB',40,'2015-02-04','2015-02-01'),('B','Joe','CatA',10,'2015-01-01','2015-01-01'),('B','Joe','CatB',10,'2015-01-02','2015-01-01'),('B','Joe','CatB',40,'2015-01-04','2015-01-01'),
    ('B','Joe','CatA',100,'2015-02-01','2015-02-01'),('B','Joe','CatB',100,'2015-02-02','2015-02-01'),('B','Joe','CatA',300,'2015-02-03','2015-02-04')
    SELECT t.BusinessType,t.SalesPerson,t.Category,
    SUM(CASE WHEN OrderDate >= monthStart AND DocumentDate < today THEN OrderAmount ELSE 0 END) AS MTDActualAmount,
    SUM(CASE WHEN OrderDate BETWEEN prevMonthStart AND prevMonthENd AND DocumentDate >= yearStart THEN OrderAmount ELSE 0 END) AS MTDPrevActualAmount
    FROM @t1 t
    INNER JOIN calendar c
    ON today = CAST(CURRENT_TIMESTAMP AS DATE)
    Group by t.BusinessType,t.SalesPerson,t.Category

  • Multi-month, year, and date-range views

    My apologies for wasting everyone's time if I've missed something really obvious here, but am I correct in concluding that there is no way to generate anything beyond a static one-month view in iCal? No multi-month view? No year view? No "view date range"? At this stage of the game, how is it possible that something so elemental could be omitted from this program?
    At this point I'm reduced to exporting each month to a pdf file and then arranging them as tiles on the screen. But there has to be a better way.
    Short of a new version from Apple, are there any plug-ins that would do this? Does anyone have any other work-arounds? Thanks in advance.

    A quick search of the forums shows that this is a HIGHLY sought after feature (including by me). We all need to use the feed back link (below) to let Apple know this. In my experience with the tech support folks, they seem to have NO idea about what these forums say. In the past I have actually had them log in to these forums and search the issue I was calling them about and they have been blown away when they see the hundreds / thousands of posts with the very same thing they're discussing with me. So, as the wise man says .. "you don't ask, you don't get!" Use the form and let them know...
    http://www.apple.com/feedback/ical.html

  • Count days in a month for a date range

    i am trying to find no. of days between 2 Date Ranges for a list of Ids. i used the logic in the below link:
    count days of the month
    My query is giving duplicates since, I have list of Ids.
    Doctor_ID     Patient_ID     ARRIVE_DT_TM     DISCH_DT_TM
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45
    763305     42972232     1/7/2013 20:27     3/15/2013 19:15
    25391509     42972298     2/4/2013 22:45     3/8/2013 22:03
    746779     42972331     1/4/2013 23:00     3/26/2013 21:50
    763305     42972338     3/4/2013 22:19     3/6/2013 19:35
    763305     42972411     11/4/2013 22:32     3/29/2013 17:30
    I am looking for query to give me for Patient_ID = 42972229
    MONTH     COUNT_DAYS
    201210     14
    201211     30
    201212     31
    201301     31
    201302     28
    201303     14
    I am running the following code and it loops through the months and gives duplicates when I remove where Patient_id IN (42972229)
    select
    Doctor_ID
    , Patient_ID
    , AR_DTTM
    , DSC_DTTM
    , TO_CHAR(ADD_MONTHS(TRUNC(date1, 'MONTH'), LEVEL - 1), 'YYYY MM') MONTHS_BET
    , (LEAST(date2, ADD_MONTHS(TRUNC(date1, 'MONTH') - 1, LEVEL)) - GREATEST(date1, ADD_MONTHS(TRUNC(date1, 'MONTH'), LEVEL - 1)))+ 1 AS DAYSCOUNT
    from (select
    Doctor_ID
    , Patient_ID
    , ARRIVE_DT_TM AR_DTTM
    , DISCH_DT_TM DSC_DTTM
    ,TRUNC(ARRIVE_DT_TM,'DDD') AS date1
    ,TRUNC(DISCH_DT_TM,'DDD') AS date2
    from temp where Patient_id IN (42972229)
    CONNECT BY LEVEL <= MONTHS_BETWEEN(TRUNC(date2, 'MONTH'), TRUNC(date1, 'MONTH')) + 1
    Please help!

    Hi,
    ASTRA_007 wrote:
    Results I would like to see are:
    Doctor_ID     Patient_ID     ARRIVE_DT_TM     DISCH_DT_TM     Month     CountofDays
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2012 10     14
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2012 11     30
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2012 12     31
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2013 01     31
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2013 02     28
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2013 03     14
    763305     42972232     1/7/2013 20:27     3/15/2013 19:15     2013 01     25
    763305     42972232     1/7/2013 20:27     3/15/2013 19:15     2013 02     28
    763305     42972232     1/7/2013 20:27     3/15/2013 19:15     2013 03     15
    and so on...So each row represents a patient-month, and you want to display several columns from the temp table on each output row. In that case, include all those columns in both the SELECT and GROUP BY clauses, like this:
    WITH     universe     AS
         SELECT     *
         FROM     temp
    --     WHERE     patient_id     IN (42972229)
    ,     date_range     AS
         SELECT     TRUNC (MIN (arrive_dt_tm))     AS first_date
         ,     TRUNC (MAX (disch_dt_tm))     AS last_date
         FROM     universe
    ,     all_dates     AS
         SELECT     first_date + LEVEL - 1     AS a_date
         FROM     date_range
         CONNECT BY     LEVEL     <= (last_date + 1) - first_date
    SELECT    u.doctor_id
    ,       u.patient_id
    ,       u.arrive_dt_tm
    ,       u.disch_dt_tm
    ,       TO_CHAR ( TRUNC (a.a_date, 'MONTH')
                  , 'YYYY MM'
                )          AS month
    ,       COUNT (*)          AS count_days
    FROM       all_dates  a
    JOIN       universe   u  ON  a.a_date  BETWEEN  TRUNC (u.arrive_dt_tm)
                                         AND      u.disch_dt_tm
    GROUP BY  u.doctor_id
    ,       u.patient_id
    ,       u.arrive_dt_tm
    ,       u.disch_dt_tm
    ,         TRUNC (a.a_date, 'MONTH')
    ORDER BY  u.patient_id
    ,       TRUNC (a.a_date, 'MONTH')
    ;Output from your sample data (with no filtering):
    `DOCTOR_ID PATIENT_ID ARRIVE_DT_TM     DISCH_DT_TM      MONTH   COUNT_DAYS
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2012 10         14
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2012 11         30
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2012 12         31
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2013 01         31
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2013 02         28
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2013 03         14
        763305   42972232 1/7/2013 20:27   3/15/2013 19:15  2013 01         25
        763305   42972232 1/7/2013 20:27   3/15/2013 19:15  2013 02         28
        763305   42972232 1/7/2013 20:27   3/15/2013 19:15  2013 03         15
      25391509   42972298 2/4/2013 22:45   3/8/2013 22:3    2013 02         25
      25391509   42972298 2/4/2013 22:45   3/8/2013 22:3    2013 03          8
        746779   42972331 1/4/2013 23:0    3/26/2013 21:50  2013 01         28
        746779   42972331 1/4/2013 23:0    3/26/2013 21:50  2013 02         28
        746779   42972331 1/4/2013 23:0    3/26/2013 21:50  2013 03         26
        763305   42972338 3/4/2013 22:19   3/6/2013 19:35   2013 03          3
    In the end the objective is to count the no. of days in each month between the arrival and discharge dates by Physician and for his/her patients.Then is the output above really what you want? Say you're interested in physician 763305. That physician had 18-patient days in March, 2013, but the output doesn't make it clear.
    I ran your query, it works great but I have a long list of patients for whom I have to run these counts.the query above includes all patient_ids.
    That's a separate problem, to be solved in the first sub-query, universe. The rest of the query will be unchanged.
    How will you know which patients to include? If you can derive the list from temp itself, just use a WHERE clause in universe. If you need to look at other tables, join them in universe, or use them in sub-queries in universe, or both.
    For exmple, if you decide that the list of patient_ids has no pattern, and that you'll need to store their ids in a separate table (perhaps a global temporary table), then universe might be:
    WITH     universe     AS
         SELECT     t.*     -- or list columns needed
         FROM     temp                        t
         JOIN     patient_ids_to_include  p 
                      ON  p.patient_id = t.patient_id
    ) ...The rest of the query can be the same as above.
    If a same patient is admitted again then Patient_ID will be different no matter when readmitted.Are you saying that patient_id identifies a visit, not a patient, and that the same person is assigned a different patient_id every time that person is admitted?
    For
    INSERT INTO temp (doctor_id, patient_id, arrive_dt_tm, disch_dt_tm)
    VALUES ( 755722
    , 42972229
    , TO_DATE ('03/14/2013 23:00', 'MM/DD/YYYY HH24:MI')
    , TO_DATE ('04/01/2013 12:00', 'MM/DD/YYYY HH24:MI')
    First the Patient ID will be different from the earlier admission. Second the results will show like:
    Doctor_ID     Patient_ID     ARRIVE_DT_TM     DISCH_DT_TM     Month     CountofDays
    755722     42972229     3/14/2013 23:00     4/1/2013 12:00     2012 03     14
    755722     42972229     3/14/2013 23:00     4/1/2013 12:00     2012 04     1Are you saying that temp.patient_id is unique, and so the situation is impossible?
    Edited by: Frank Kulash on May 7, 2013 10:23 AM

  • Function to list the month from a date range?

    I would like to know what the function is that would take a look at a date range, and extract the month name
    Here is how I would like it to come out:

    Hello
    The following sample tables are along your original scheme using month name to filter the data.
    2014 (excerpt)
    A1  month
    A2  =MONTHNAME(MONTH(B2))
    A3  =MONTHNAME(MONTH(B3))
    A4  =MONTHNAME(MONTH(B4))
    B1  date
    B2  2013-01-15
    B3  2013-01-20
    B4  2013-01-27
    C1  category
    C2  A
    C3  B
    C4  C
    D1  amount
    D2  100
    D3  50
    D4  20
    January
    A1  category
    A2  A
    A3  B
    A4  C
    A5  D
    A6  E
    A7  F
    A8  G
    A9  H
    B1  totals
    B2  =SUMIFS(2014::D,2014::A,C$1,2014::C,A2)
    B3  =SUMIFS(2014::D,2014::A,C$1,2014::C,A3)
    B4  =SUMIFS(2014::D,2014::A,C$1,2014::C,A4)
    B5  =SUMIFS(2014::D,2014::A,C$1,2014::C,A5)
    B6  =SUMIFS(2014::D,2014::A,C$1,2014::C,A6)
    B7  =SUMIFS(2014::D,2014::A,C$1,2014::C,A7)
    B8  =SUMIFS(2014::D,2014::A,C$1,2014::C,A8)
    B9  =SUMIFS(2014::D,2014::A,C$1,2014::C,A9)
    C1  January
    C2 
    C3 
    C4 
    C5 
    C6 
    C7 
    C8 
    C9 
    Notes.
    Formula in January::B2 can be filled down across B2:B9.
    The target month name is defined in January::C1.
    February table is the same as January table except for the value in C1.
    And the following sample tables are using date per se instead of month name to filter the data. In this scheme, you don't need month column in source table but the retrieving formulae in destination table become more complex.
    2014 (excerpt)
    A1  date
    A2  2013-01-15
    A3  2013-01-20
    A4  2013-01-27
    B1  category
    B2  A
    B3  B
    B4  C
    C1  amount
    C2  100
    C3  50
    C4  20
    January
    A1  category
    A2  A
    A3  B
    A4  C
    A5  D
    A6  E
    A7  F
    A8  G
    A9  H
    B1  totals
    B2  =SUMIFS(2014::C,2014::B,A2,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
    B3  =SUMIFS(2014::C,2014::B,A3,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
    B4  =SUMIFS(2014::C,2014::B,A4,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
    B5  =SUMIFS(2014::C,2014::B,A5,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
    B6  =SUMIFS(2014::C,2014::B,A6,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
    B7  =SUMIFS(2014::C,2014::B,A7,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
    B8  =SUMIFS(2014::C,2014::B,A8,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
    B9  =SUMIFS(2014::C,2014::B,A9,2014::A,">="&EOMONTH(C$1,-1)+1,2014::A,"<="&EOMONTH(C$1,0))
    C1  2013-01-01
    C2 
    C3 
    C4 
    C5 
    C6 
    C7 
    C8 
    C9 
    Notes.
    Formula in January::B2 can be filled down across January::B2:B9.
    The target month is defined in January::C1, which can be any date in target month, e.g., 2013-01-01, 2013-01-20, etc. The formulae in B will retrieve data with date in range: 2013-01-01 <= [date] <= 2013-01-31.
    February table is the same as January table except for the value in C1.
    Tables are built in Numbers v2.
    Hope this may help,
    H
    EDIT: Replaced the last table with the correct one. (Formulae in B are correct)

  • VL10h - 1 month default delivery date range

    Dear Sirs,
    I am using VL10h to create deliveries from Sales Order. But, The default date range it takes is only 1 month. Would you please suggest me to increase the date range?
    The message I am getting is-
    Latest deliv. creation date (04.12.2009) further in future than allowed (30 days)
    Message no. V50R014
    Diagnosis
    Maximum future delivery time frame was exceeded.
    System Response
    In your system, the maximum delivery creation time frame is limited to 30 days in the future. However, you want to deliver until 04.12.2009, which the system does not allow.
    Procedure
    Choose a smaller interval for delivery.
    Procedure for System Administration
    You can set the number of days in the future the delivery is limited to in Customizing in Create deliveries profiles 0101, which is assigned to the current list profile "Sales Order and Purchase Order Items".
    regards,
    rahul

    Dear Rahul
    To avoid the error message V50R014 you have to change the value of the
    field "Maximum delivery period in the future"  (transaction VL10CUC).  Alternatively, maintain the delivery creation profile in transaction VL10H for the field "Maximum delivery period in the future".
    Hope this helps.
    Regards
    Tonia

  • Assign Month within a date range (by most days in a given month)

    I have a begin and end date, sample data as such
    select to_date('01-13-12','mm-dd-yy') from_dt,
    to_date('02-23-12','mm-dd-yy') to_dt
    from dual
    union all
    select to_date('03-15-2012','mm-dd-yy') from_dt,
    to_date('04-16-2012','mm-dd-yy') to_dt
    from dual
    union all
    select to_date('05-13-2012','mm-dd-yy') from_dt,
    to_date('07-23-2012','mm-dd-yy') to_dt
    from dual
    How do I assign a month by the most days in a month within that date range? Sometimes the date range might have the exact same amount of days in a month (like 3/15/2012 has 16 days and 4/16/2012 has 16 days). In this case, I want the earlier month (march).
    So from the sample data:
    01/13/2012, 02/23/2012, February
    03/15/2012, 04/16/2012, March
    05/13/2012, 07/23/2012, June
    Thanks
    Edited by: user4422426 on Mar 1, 2012 5:15 PM

    Hi,
    Here's one way:
    WITH     cntr          AS
         SELECT     LEVEL - 1     AS n
         FROM     (
                   SELECT      1 + MAX (to_dt - from_dt)     AS max_day_cnt
                   FROM     table_x
         CONNECT BY     LEVEL     <= max_day_cnt
    ,     got_r_num     AS
         SELECT     x.from_dt, x.to_dt
         ,     TRUNC (x.from_dt + c.n, 'MONTH')     AS month
         ,     count (*)                    AS cnt
         ,     ROW_NUMBER () OVER ( PARTITION BY  from_dt, to_dt
                             ORDER BY        COUNT (*)     DESC
                             ,             TRUNC (x.from_dt + c.n, 'MONTH')
                           )     AS r_num
         FROM       cntr     c
         JOIN       table_x  x  ON  c.n  <= x.to_dt - x.from_dt
         GROUP BY  x.from_dt, x.to_dt
         ,       TRUNC (x.from_dt + c.n, 'MONTH')
    SELECT     from_dt, to_dt
    ,     TO_CHAR (month, 'Mon YYYY')     AS mon
    ,     cnt
    FROM     got_r_num
    WHERE     r_num     = 1
    ;Thanks for posting code to create the same data. Please test your code before you post it: you got the order of arguments to TO_DATE reversed.

  • Different totals based on dates (month vs date range)

    I know I've seen this before, but I can't find the thread. I have a column in a fact table for price. When I add price and the month (eg April 2012) from the time dimension, it totals one number, but when I remove the month, and add a date range (4/1/2012 - 4/30/2012) it totals another (lower value). I can't find the solution I found last time.
    Anyone else run into this? and solve it?

    RiZapata wrote:
    I know I've seen this before, but I can't find the thread. I have a column in a fact table for price. When I add price and the month (eg April 2012) from the time dimension, it totals one number, but when I remove the month, and add a date range (4/1/2012 - 4/30/2012) it totals another (lower value). I can't find the solution I found last time.
    Anyone else run into this? and solve it?The solution is to understand what OBIEE is doing. If the totals differ, then the definitions are different. You need to troubleshoot to see what the difference is. When you add the month column and the date (so you can see every date) and add the total then, which total does it tie to? Is there rounding? How off are the two totals? That often may give a clue as to what is missing in the lower total.

  • How to convert Date,month,date range row to column

    hi experts
    i have a requirement like
    i want to change date, month and if user key in date range (01-04-2010 to 31-04-2010) then o/p like below
    1st-o/p-format
    d1 d2 d31
    01-04-2010 02-04-2010 ------------------------------- 31-04-2010
    2nd-o/p-format -based on transaction month
    d1 d2 d31
    jan feb ------------------------------------------ mar
    3rd-o/p-format date range based on transaction date
    d1 d2 d31
    01-04-2008 02-04-2010 -------------------------------31-04-2009
    Note :Basically i want to display these formate in Oracle Forms then based these dates i want to fetch record like below:
    d1 d2 d31
    jan feb dec
    count sales amt avgsales count sales amt avgsales ------------------ count sales amt avgsales
    so can anyone tell me what approach i shouls apply..
    Thanks
    abhishek

    This forum is titled "Certification" - pl post in the PL/SQL or Database General forums for a better/faster response.
    HTH
    Srini

  • All months in date range plus running count

    Oracle 11g
    Hello all,
    Having trouble getting the following query to return proper results. Have a table with a MEMBERNO, BUSINESS_LINE, ELIGIBILITY_START_DATE, ELIGIBILITY_END_DATE.
    MEMBERNO is not unique
    BUSINESS_LINE is not either
    Start and end date are periods of time where: MEMBERNO&BUSINESS_LINE have changed
    I need to list the member number, business_line, and each month that falls within the date range beginning with eligibility_start_date & eligibility_end_date, as well as a running count of the total in that span.
    Eg.
    member, business_line, month, year, count
    1234, bus1, 01, 2001, 1
    1234, bus1, 02, 2001, 2
    1234, bus1, 03, 2001, 3
    Here is my SQL, it is not sequencing the months dates correctly and I can not figure out why. Any help is very appreciated:
    SELECT memberno,
    business_line,
    TO_CHAR (ADD_MONTHS (start_date, LEVEL - 1), 'MM') as MONTH,
    TO_CHAR (ADD_MONTHS (start_date, LEVEL - 1), 'YYYY') as YEAR,
    ROW_NUMBER () OVER (PARTITION BY key1 ORDER BY start_date ASC) as MEMBER_MONTH_COUNT
    FROM (SELECT memberno,
    business_line,
    eligibility_start_date as start_date,
    eligibility_end_date as end_date,
    member_nbr || business_line as key1
    FROM eligibility)
    CONNECT BY LEVEL <=
    MONTHS_BETWEEN (TRUNC (END_DATE, 'MM'),
    TRUNC (START_date, 'MM'))
    + 1;
    Edited by: 935047 on Jul 25, 2012 5:58 AM
    Edited by: 935047 on Jul 25, 2012 6:18 AM

    935047 wrote:
    I need to list the member number, business_line, and each month that falls within the date range beginning with eligibility_start_date & eligibility_end_date, as well as a running count of the total in that span.
    Eg.
    member, business_line, month, year, count
    1234, bus1, 01, 2001, 1
    1234, bus1, 02, 2001, 2
    1234, bus1, 03, 2001, 3I could not understand what the Running Count mean. Hence, I used Row_Number (Same as you did).
    Below query might match yours.
    with data (memb_no, bus_line, st_date, end_date) as
      select 1234, 'bus1', to_date('01-01-2001', 'MM-DD-YYYY'), to_date('06-30-2001', 'MM-DD-YYYY') from dual
      union all
      select 1234, 'bus1', to_date('07-01-2001', 'MM-DD-YYYY'), to_date('07-30-2002', 'MM-DD-YYYY') from dual
    min_max as
      select memb_no, bus_line, min(st_date) st_date, max(end_date) end_date
        from data
       group by memb_no, bus_line
    lvl as
      select level l
        from dual
      connect by level <= (select max(round(months_between(end_date, st_date))) from min_max)
    select memb_no,
           bus_line,
           to_char(add_months(st_date, l - 1), 'MM') months,
           to_char(add_months(st_date, l - 1), 'YYYY') Year,
           row_number() over (partition by memb_no, bus_line order by st_date) cnt
      from min_max cross join lvl
    order by year, months;
    ----OUTPUT------------------------
    MEMB_NO BUS_LINE MONTHS YEAR CNT
       1234 bus1     01     2001   1
       1234 bus1     02     2001  19
       1234 bus1     03     2001   3
       1234 bus1     04     2001   4
       1234 bus1     05     2001   5
       1234 bus1     06     2001   6
       1234 bus1     07     2001   7
       1234 bus1     08     2001   8
       1234 bus1     09     2001   9
       1234 bus1     10     2001  10
       1234 bus1     11     2001  11
       1234 bus1     12     2001  12
       1234 bus1     01     2002  13
       1234 bus1     02     2002  14
       1234 bus1     03     2002  15
       1234 bus1     04     2002  16
       1234 bus1     05     2002  17
       1234 bus1     06     2002  18
       1234 bus1     07     2002   2
    19 rows selected

  • How to select Months with in a date range

    Hi
    I am working on a report which will list out Month wise totals in each row.
    How should i select the Months with in a date range and do the sum ( User may select the date range for  N number of  years also. Example :  01/10/2000 to 01/01/2010 )
    Thanks in advance
    Thanks&regards
    Mrudula

    Hi
       Use the following code:
    data: l_date(8) value '03042007',
            l_mname   type   t247-ktx,
            l_c(25).
      select single ktx from t247
      into l_mname
      where spras = sy-langu
      and mnr = l_date+2(2).
      concatenate l_mname l_date+6(2)
      into l_c." SEPARATED BY space.
      data: g_date(10) type c. " Processing date of Report
      g_date = sy-datum.
      concatenate g_date0(4)  g_date4(2)  g_date+6(2) into g_date.
      data: g_date1(10) type c.
      g_date1 = so_verab-high.
      concatenate g_date10(4)  g_date14(2)  g_date1+6(2) into g_date1.
    Regards,
    Sreeram

  • Variable Exit - Last Three months date range based on Sy-datum

    Hi
    I have a requirement to filter last 3months data based on sy-datum. I have a variable filter on Posting Date.
    For e.g. Today is 20110622
    I have to determine below range: When users run the report prompt should be auto filled with below date range.
    From Value: 20110301
    To Value     : 20110531
    From sy-datum I can find the first day of the current month - In this scenario 20110601 (I'll replace last 2 characters with "01").
    If I subtract "-1" I'll get the To Value: 20110531
    Question is to get the "From Value". If I subtract 90days from To value, it will work for few months.
    For e.g. If my To value is Feb 28th and if I subtract 90days, I may get a different answer.
    Is there any better approach to determine this date range?
    Thanks for your help.
    Best Regards,
    Sree

    Hi Sree,
      Pleae find this approach and compare
    data : l_date type sy-datum,
    l_startdate type sy-datum,
    l_endate type sy-datum,
    l_startmonth(6) type c,
    l_endmonth(6) type c,
    l_date = sy-datum.   say "20110622
    l_endmonth = sydatum(6)   "201106
    Pass year month and get previous month using this standard .
              CALL METHOD cl_rs_time_service=>shift_year_month
                EXPORTING
                  i_year_month = l_endmonth
                  i_shift      =  -1
                RECEIVING
                  r_year_month = l_endmonth
                EXCEPTIONS
                  failed       = 1
                  OTHERS       = 2.
    "l_endmonth = 201105.
              CALL METHOD cl_rs_time_service=>shift_year_month
                EXPORTING
                  i_year_month = l_endmonth
                  i_shift      =  -2
                RECEIVING
                  r_year_month = l_startmonth
                EXCEPTIONS
                  failed       = 1
                  OTHERS       = 2.
    "l_startmonth = 201103
    l_startdate(6) = l_startmonth.
    l_startdate+6(2) = '01'.
    "l_startdate = 20110301
    We got startdate in and we want to get enddate , but we got endmonth ...
    now we need to get last date of the endmonth.
    Use this function module SLS_MISC_GET_LAST_DAY_OF_MONTH  and u can get it. Input should be date.
    so put l_enddate+6(2) = '01'.
    l_enddate(6) = l_endmonth.
    now pass end date to the  Function module and this will return the end date of the month.
    So you get l_startdate and l_enddate as you require. This will work for leap years or feb 28 days what ever...
    Regards
    vamsi
    Edited by: vamsi talluri on Jun 22, 2011 10:06 PM

Maybe you are looking for

  • Crystal Report Chart Problem: No trendlines with regression

    Hi, I have a severe problem with chart trendlines in Crystal Reports 2008 (12.3.0.601). Trendlines with regression do not work, whereas  average and moving average work on charts with data axis but not with numerical axis. Does anyone has an idea, ho

  • BAPI for Scheduling Agreement Scales

    Hello, I want to add Scales to my Scheduling Agreement. Tried using BAPI_SAG_CREATE, I was able to successfully create a Scheduling Agreement but it says that "No scales exist". According to the FM documentation, scales are not supported during the c

  • No keys work?

    so this has happened before, but it was only my spacebar last night my O key stoped working, and it was the last key i needed to unlock my phone this morning, EVERYTHING has stopped workng, all my keys except my K (which is one of the few letters for

  • How to check who modified a file

    Hi is there any way to check who modified a file on Windows Server 2008? I tried to display the file's attribute on windows explorer, but it doesn't show anything. Thanks

  • Careful updating ipod software to 1.2.1

    I just updated My 5th Gen Ipod to 1.2.1 software,now when I use my video out to my dvr the dvr won't record. This is not copy protected stuff. I used the ipod to carry the stuff to the dvr to burn to a dvd. How can I get the previous version of the I