Display three prior months starting from current month

Hello All,
I came across the requiremnt:
The report looks like:
2014-Jan
2014-Feb
2014-Mar
2014-Apr
2014-May
2014-June
2014-July
2014-Aug
2014-Sep
2014-oct
2014-Nov
2014-Dec
A
122
233
233
233
233
233
233
233
233
233
233
233
B
22
33
33
33
33
33
33
33
33
33
33
33
C
33
33
33
33
33
33
33
33
33
33
33
33
D
333
3333
3333
3333
3333
3333
3333
3333
3333
3333
3333
3333
The requirement is to display the prior 3 months ,current month, next 3 months.
Assume that current month is SEPTEMBER, the report should look like:
2014-June
2014-July
2014-Aug
2014-Sep
2014-oct
2014-Nov
2014-Dec
A
233
233
233
233
233
233
233
B
33
33
33
33
33
33
33
C
33
33
33
33
33
33
33
D
3333
3333
3333
3333
3333
3333
3333
Share your thoughts.
Thanks

Hello All,
I got this resolved using the below formula to get either prior 3 months or the next 3 months from current date:
3rd month from current date:
=LastDayOfMonth(RelativeDate(LastDayOfMonth(RelativeDate(LastDayOfMonth(RelativeDate(LastDayOfMonth(CurrentDate()); 1));1));1))
Prior 3rd month from current date:
=ToDate(FormatDate(RelativeDate(ToDate(FormatDate(RelativeDate(ToDate(FormatDate(RelativeDate(ToDate(FormatDate(CurrentDate();"MM/yyyy");"MM/yyyy");-1);"MM/yyyy");"MM/yyyy");-1);"MM/yyyy");"MM/yyyy");-1);"MM/yyyy");"MM/yyyy")
and used these objects to restrict my date field(date object between "Prior 3rd month from current date:" and
"Prior 3rd month from current date:"
Thanks,
Vijay

Similar Messages

  • How to get previous month data from current month values

    Hi Experts,
    I have made one universe from BW Query in which Fiscal year period is entered in interval.
    I have made a universe from that and want to develop webI reports on top of that.
    In my webI reports, i have used one cross tab. In Rows section i have added Company Code and in Column section i have used Fiscal Year/Period and in Value section i have added Sales Value. I want this value of previous month.
    Requirement:
    Ex.
                            Feb'09          Mar'09     and so on...
    Comp_code1   Sales of Jan'09         Sales of Feb'0f         and so on....
    I am getting this.
    Ex.
                            Feb'09          Mar'09     and so on...
    Comp_code1   Sales of Feb'09         Sales of Mar'09         and so on....
    I hope i have clear my requirements.
    Please help as soon as possible.
    Thanks in Advance,
    Rishit

    Hi Rishit,
    Follow the below steps to get the desired result.
    Step1: Convert your fiscal year period from char to a date in your database or in your designer however its feasible.
    to_date('substr('009.2009',2)','mm.yyyy')
    you will get the result 01 sep 2009
    Step2: Convert this format to 01/09/2009 by using date functions.
    Step3: Create a Detail associated to the 'date' field (typically your fiscal period).
    Step4: Create a cross tab Like : Rows section should have Company Code and in Column section should have 'date'(created detail) and in Value section should be Sales Value.
    you should get the following result.
    01/02/2009 01/03/2009 and so on...
    Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
    Step5: Use the following formula in your Column (date) formula bar.
    =(<date>-1)-DayNumberOfMonth(<date>-1)+1
    You will get the following result:
    01/01/2009 01/02/2009 and so on...
    Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
    Format the cell according to your reruirement.
    Let me know if you will get any break in the above steps.
    Regards,
    Swati.

  • Customer Exit for 13 month from current month

    Hi Gurus,
    I need a customer exit for 13 months from current month. Based on the requirement I have written following code
    When 'VPI_13CALYRMON'.
        IF i_step = 1.
          l_s_range-sign = 'I'.
          l_s_range-opt = 'BT'.
          l_s_range-low = sy-datum+0(6).
          l_s_range-high = sy-datum+0(6) + 13.
          append l_s_range to e_t_range.
        endif.
    Please could you guide me the code.
    Thanks
    Ganesh Reddy.

    Hi,
    I think you can do it in below way.
    When 'VPI_13CALYRMON'.
    IF i_step = 1.
    temp1 = sy-datum+0(4).
    temp1 = temp1 +1. (because adding 13 months would take year to next year)
    temp2 = sy-datum+4(2).
    temp2 = temp2 + 1. (after adding 13 months, the month would be one more than of previous year)
    concatenate temp1 temp2 into temp3.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'BT'.
    l_s_range-low = sy-datum+0(6).
    l_s_range-high = temp3.
    append l_s_range to e_t_range.
    endif.
    Hope this helps.

  • Average salary for 12 months start from a specific date

    Hi Expert,
    If we want to calculate the  average for past 12 past month, starting from a past date, any idea how to achieve this?
    E.g.  I would like to have the average for past 12 months, starting from  01.Nov 2014,  i.e. the required periods are Nov 2013 to Oct 2014
    Thanks

    Go through below link you may get an idea.
    Payroll processing - Calculate average 6 month Basic Salary
    Regards
    Venkatesh

  • Customer Exit for 15 month from current month

    Hi Gurus,
    I have a requirement to write customer exit for 15 months from current month based on todays day.
    if current day is less than 10 then we have to get 15 months from current month other wise from next month to 15 months.
    this exit I am writing on calendar year/month.
    Please assist for logic.
    Thanks
    Ganesh Reddy.

    I hope this code will do the trick.
    DATA: L_S_RANGE TYPE RSR_S_RANGESID,
    LOC_VAR_RANGE LIKE RRRANGEEXIT,
    zcalmonth(6) type c.
    zcurrentmonth(6) type c.
    zyear(4) type n,
    znextyear(4) type n,
    zyear1(4) type c,
    znextyear1(4) type c,
    zmonth(2) type n,
    zmonth1(2) type n,
    zmonth2(2) type c,
    zmonth3(2) type n,
    zmonth4(2) type c,
    IF i_step = 2.
    CASE i_vnam.
    WHEN '<VARNAME>'.
    zyear = sy-datum+0(4).
    znextyear = zyear + 1.
    zyear1 = zyear.
    znextyear1 = zlastyear.
    zmonth = sy-datum+4(2).
    if sy-datum+6(2) LE 10.
    zmonth1 = zmonth + 2.
    if zmonth1 GT 12.
    zmonth1 = zmonth1 - 12.
    zmonth2 = zmonth1.
    zcurrentmonth = sy-datum+0(6).
    endif
    concatenate znextyear1 zmonth2 into zcalmonth.
    else.
    zmonth1 = zmonth + 3.
    ZMONTH3 = ZMONTH + 1.
    if zmonth1 GT 12.
    zmonth1 = zmonth1 - 12.
    zmonth2 = zmonth1.
    endif
    if zmonth3 GT 12.
    zmonth3 = zmonth3 - 12.
    zmonth4 = zmonth3.
    endif
    concatenate znextyear1 zmonth2 into zcalmonth.
    concatenate znextyear1 zmonth4 into zcurrentmonth.
    endif.
    l_s_range-low = zcurrentmonth.
    l_s_range-high = zcalmonth.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'BT'.
    APPEND l_s_range TO e_t_range.
    ENDIF.
    ENDIF.
    rgds, Ghuru

  • Retrieving remaning months of current year from current month

    Hi,
    I would like te retrieve the remaining months of current year from current date.
    I can I achieve this?
    For example today is 23 july 2012.
    Then I would like to have:
    August
    September
    October
    November
    December
    Thanks,
    Diana

    Something like this:
    with generate_months as (select to_char(add_months(trunc(sysdate, 'mm'), level -1), 'fmMonth', 'nls_date_language=english') months, level lvl
                             from   dual
                             connect by level <= months_between(add_months(trunc(sysdate, 'yyyy'), 12), trunc(sysdate, 'mm')))
    select months
    from   generate_months
    where  lvl != 1;
    MONTHS  
    August  
    September
    October 
    November
    December Edited by: Boneist on 23-Jul-2012 16:42
    Fixed the query so that it wouldn't show any months when sysdate is in December.
    Also, this is a duplicate of retrieving remaning months of current year from current month (shame I didn't spot that before adding my solution! Oh well...)

  • SQL Query to add previous month amount to current month amount

    Beginner - Using SQL 2008 R2 - Having a difficult time adding previous month amount to current month amount on a continual running basis. Table fields and example data are:
    FunctionID    
    UnitID     
    Dateof           
    Result       YTD
    A                   AA           01/01/2014    10             10
    A                   AA           02/01/2014    10            
    20
    A                   AA           03/01/2014     15           
    35
    B                  BB            01/01/2014     20          
    20
    B                  BB            02/01/2014     10           30
    The YTD field would be a calculated field. I would need to be able start a new YTD in Jan of the next year. Really could use some help and direction on this one. Easy to do in an Excel spreadsheet. Can't seem to get it in SQL. Thanks in advance.

    As of 2008 R2 the choices are:
    - Self join
    - Correlated subquery (in the SELECT or APPLY clauses)
    - Cursor
    - SQLCLR aggregation function (winner)
    The first two options yield a poor performance for tables with considerable number of rows.
    Example:
    select
        A.*, 
        select
            sum(B.Result)
        from
            T as B
        where
            B.FunctionID = A.FunctionID
            and B.UnitID = A.UnitID
            and B.Dateof >= dateadd(year, datediff(year, '19000101', A.Dateof), '19000101') --bofyear
            and B.Dateof <= A.Dateof
        ) as YTD
    from
        T as A;
    Check these old but very interesting posts from Adam Machanic.
    http://sqlblog.com/blogs/adam_machanic/archive/2006/07/12/running-sums-redux.aspx
    http://sqlblog.com/blogs/adam_machanic/archive/2006/07/12/running-sums-yet-again-sqlclr-saves-the-day.aspx
    The things get easier from SS 2012 with the enhanced OVER clause (introduction of window frame extent).
    select
        sum(Result) over(
        partition by FunctionID, UnitID, year(Dateof) 
        order by Dateof
        rows between unbounded preceding and current row
        ) as YTD
    from
        T;
    http://sqlmag.com/sql-server-2012/sql-server-2012-how-write-t-sql-window-functions-part-3
    AMB
    Some guidelines for posting questions...
    AYÚDANOS A AYUDARTE, guía básica de consejos para formular preguntas

  • Last/latest 10 months data ( including current month)

    Hi,  
    I need to find the last/latest 10 months data ( including current month)
    Year
    1/1/2014
    1/2/2014
    1/3/2014
    1/4/2014
    1/5/2014
    1/6/2014
    1/7/2014
    1/8/2014
    1/9/2014
    1/10/2014
    1/11/2014
    1/12/2014
    1/1/2013
    1/2/2013
    1/3/2012
    1/4/2012

    Hi,
    this is my data 
    Year column with Nvarchar datatype. 
    Year
    1/1/2014
    1/2/2014
    1/3/2014
    1/4/2014
    1/5/2014
    1/6/2014
    1/7/2014
    1/8/2014
    1/9/2014
    1/10/2014
    1/11/2014
    1/12/2014
    1/1/2013
    1/2/2013
    1/3/2012
    1/4/2012
    now form this yea) column i need to fetch the latest/last 10 months data only .
    OutpUt for the Query to be:
    Year
    1/3/2014
    1/4/2014
    1/5/2014
    1/6/2014
    1/7/2014
    1/8/2014
    1/9/2014
    1/10/2014
    1/11/2014
    1/12/2014
    Hope this will give you clear picture

  • Want to show data from current month & prev month in single record on forms?

    Hello experts,
    i have this requirement:
    Table structure:
    MOnth       Division         totalAmount
    01-apr-2013      1               10000
    01-May-2013    1               20000
    01-apr-2013      2               30000
    01-May-2013    2               50000
    i want to display in forms like
    Form:
    Month  : 01-May-2013
    Month               Division               total               prev_Month          division               total                         dIFFERENCE
    01-May-2013               1              10000                01-Apr-2013               1               20000                        10000
    01-May-2013               2              30000                01-Apr-2013               2               50000                        20000
    I am using two procedure for fetching records for current month and previous month.
    but it will cause problem, if for some division previous month data not present.
    please suggest me some query with which i can fetch current and pre month data in single record.
    Please help me out.
    Thanks
    yash

    I'M NOT SURE BUT TRY IT ............
    select x.mn mnth, x.division, x.totalAmount total, y.mn prev_month,  y.division, y.totalAmount total, (y.totalAmount - nvl(y.totalAmount,0)) difference
    from
      (select month mn, division, totalAmount
      from table_name
      where month = (select max(month)
      from table_name
      ) x,
      (select month mn, division, totalAmount
      from table_name
      where month = (select add_months(max(month),-1)
      from table_name
      ) y
    where x.division = y.division(+)
    MOSTAFIZ MITUL
    DHAKA BANGLADESH

  • To show previous 12 months from current month.

    I have one column Time.Month (Char column) with values in the format 2011 / 09. In my report i want to show previous 12 months from the current month. I dont have any date prompts in my report. Pls help.

    Use the below query in init block to create a repository variable as PREVIOUS_12_MONTH
    SELECT PRV.PER_NAME_MONTH FROM VALUEOF(OLAPTBO).W_DAY_D PRV , VALUEOF(OLAPTBO).W_DAY_D CUR WHERE convert(char(12),PRV.DAY_DT)=convert(char(12),CUR.YEAR_AGO_DT) AND convert(char(12),CUR.DAY_DT)=convert(char(12),getdate()-valueof(time_offset))
    Variable PREVIOUS_MONTH: Use the below query in init block
    SELECT PRV.PER_NAME_MONTH FROM VALUEOF(OLAPTBO).W_DAY_D PRV , VALUEOF(OLAPTBO).W_DAY_D CUR WHERE convert(char(12),PRV.DAY_DT)=convert(char(12),CUR.MONTH_AGO_DT) AND convert(char(12),CUR.DAY_DT)=convert(char(12),getdate()-valueof(time_offset))
    Create a filter in Answers as below and use where ever you wish:
    Month is between PREVIOUS_12_MONTH and PREVIOUS_MONTH
    Use it in the report with current month Or previous month as per your requirements.
    Pls mark if helps

  • How to take last months date to current month date

    Hi,
    I am designing a report wherein the data should range from 12:01am on the 28th day of the previous month to 11:59 pm on the 27th of the current month..  Also this report would be scheduled accordingly and I should  not be able to modify the report every month.  What is the formula that should go into it.
    Any help will be greatly appreciated!
    Thanks & Regards
    Cauvery

    Hi Cauvery,
    try to use the following formula :
    Local DateTimeVar A;
    Local DateTimeVar From_;
    Local DateTimeVar To__;
    A:=today;
    if Month(A)=1
    then From_:=Datetime(year(A),12,28,0,1,0)
    else From_:=Datetime(year(A),Month(A)-1,28,0,1,0);
    To__:=Datetime(year(A),Month(A),27,23,59,0);
    Regards
    Edited by: jeecech on Apr 17, 2009 9:37 AM

  • Getting 1st of Month Previous To Current Month

    Hello, trying to get the first of the month previous to the current month. So if Sysdate is 6/10/20, then I want 5/1/2010 returned for criteria..
    No idea how to go about this, any help is appreciated..

    Hi
    select trunc(add_months(sysdate,-1),'MM') as previous_month from dual;regards,
    David.

  • How do I set my iTunes to start from current song on my iPhone 5?

    How do I set my iTunes to start from the current song on my iPhone 5?

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • Calculating Previous Month(s) From Current Date

    Greeting JavaScripting Gurus!
    I would like to ask for some assistance on Date Calculation.
    Here is my current scenario:
    The user inputs a date mm/dd/yyyy ("DateField")
    The powers that be over here are asking for the "DateField" to then calculate these items:
    "DateField" minus(-) 12 months = mm/yyyy ("12MonthsAgoDateField")
    "DateField" minus(-) 18months = mm/yyyy ("18MonthsAgoDateField")
    "DateField" minus(-) 36 months = mm/yyyy ("36MonthsAgoDateField")
    and so on...
    I've read some of the Date Calculation posts, but could no seem to find anything that fit this scenario.
    I freely confess my javascripting ability is very minor.
    I would greatly appreciate any help in scripting this.
    Thank you!

    Unfortunately the numbers of days in a month or year are not the same for all months or years, so the get and set date methods might not work. Fortunately there are the getMonth() and setFullYear() methods for getting or setting the month or year for a given date.
    For the "On Blur" action for the "DateField" you can use:
    function GetField(cName) {
    // get a field object with error catching;
    var oField = this.getField(cName);
    if(oField ==  null) app.alert("Error accessing field named: " + cName, 0, 0);
    return oField;
    } // end GetField function;
    function AddMonths(oDate, nMonths) {
    // add nMonths to oDate object;
    oDate.setMonth(oDate.getMonth() + nMonths);
    return oDate; // return adjusted date object;
    } // end AddMonths;
    function Scand(cFormat, cDate) {
    var oDate = util.scand(cDateFormat, event.value);
    if(oDate == null) app.alert("Error converting " + oDate.valueAsString + " with format: " + cDateFormat, 0, 0);
    return oDate;
    } // end Scand functon;
    var cDateFormat = "mm/dd/yyyy"; // format for date strings;
    // event value is the start date string;
    // 12 months ago;
    var o12MonthsAgo = GetField("12MothsAgoDateField")
    var oDate = Scand(cDateFormat, event.value);
    oDate = AddMonths(oDate, -12) // subtract 12 months;
    o12MonthsAgo.value = util.printd(cDateFormat,oDate);
    // 18 months ago;
    var o18MonthsAgo = GetField("18MothsAgoDateField")
    oDate = Scand(cDateFormat, event.value);
    oDate = AddMonths(oDate, -18) // subtract 18 months;
    o18MonthsAgo.value = util.printd(cDateFormat, oDate);
    // 36 months ago;
    var o36MonthsAgo = GetField("36MothsAgoDateField")
    oDate = Scand(cDateFormat, event.value);
    oDate = AddMonths(oDate, -36); // subtract 36 months;
    o36MonthsAgo.value = util.printd(cDateFormat, oDate);
    // and so on;
    Since getting a field object, converting a date string to a date object and adjusting the date object using the getMonth and setMonth methods are repeated several times I have used functions so the repeated code could be reused.

  • Product Revenue over several months starting from a different date

    Hi,
    I have a question regarding product revenue. You can indicate for how many months certain opportunities generate revenue, right? Is this visible in the reports and is is it also possible to indicate the date when this opportunity will start taking place? Which variable should I use?
    Any suggestions are more than welcome!
    Thanks in advance
    Kind regards
    Vincent

    Hi Vincent,
    If you are reporting at opportunity level:
    If you have an opportunity without any associated products, the 'Expected Close Date' defines when the Opportunity is due to close and when the revenue will be recognised within your sales pipeline. You'll notice at this point the field Date.Date should match the 'Expected Close Date'
    If you are reporting at product level:
    When you add a product to your opportunity the Opportunity Product.Start/Close Date field indicates when the revenue for that particular product starts. If you populate the # Periods and Frequency a new period is added each time accordingly (A new date.date). For example, you add a product with a frequency of monthly and a # periods of 3. The product is set to £100 of revenue per period. You report would be as follows:
    Product Date Revenue
    A 01/07/2009 £100
    A 01/08/2009 £100
    A 01/09/2009 £100
    To find the date the opportunity starts you need to search for the Minimum Start Date out of all of your products.. You can use something along the lines of: MIN('Start/Close Date' by 'Opportunity ID'). To find out when it ends just replace MIN with MAX. To find the duration you can check the difference between the Min and Max dates, you could do something like: TIMESTAMPDIFF(SQL_TSI_DAY, MIN('Start/Close Date' by 'Opportunity ID', MAX('Start/Close Date' by 'Opportunity ID'). This returns the duration in days.
    The syntax above isn't correct, you'll need to substitute the exact field names within the code but it should give you a good idea.
    Thanks
    Oli @ Innoveer

Maybe you are looking for

  • How can I get my camera to use auto frame - flex mode in the "P" mode. I can't get it.

    When I use the "P" mode for stills Auto Frame is not highlighted and so I cannot get Flex Mode.   Is there something wrong with my camera or is Flex Mode only available for C1 or C2.  Page 266 of the manual says its available yet there is not way I c

  • VF02 - CHANGE BILLING DOCUMENT

    Hi All, I had a requirement, In the Transaction VF02(CHANGE BILLING DOCUMENT) after the SD billing document is created and when the option 'ReleaseToAccounting' is selected an OutBound Idoc should be created for the FI InvoiceHi All, My question is h

  • Need help using ADF objects directly from a JAVA Class

    Hi Everybody I ma new in jdeveloper, what I am doing is an application that does not have visual interface. I created business objects for my tables, then I generated the java classes. In a function in my class I created and instance of mytableImpl.j

  • Ideacentre k330B Motherboard, CIH61M v1.0, what PCIe-express slot is it? 1,2 or 3?

    I have an Ideacentre K330B and the MoBo is CIH61M v1.0, I want my video card and i'm curioius as to what PCIe-Express slot it is. Is it PCIe-Express 1,2 or 3?

  • Dynamica SQL

    We have created a lot of "MATERIALIZED" views for each parameter values. For example, for parameter A, we would like to use materialized view A. So the final sql would be "SELECT * FROM materialized_view_A". And for parameter B, we would like to use