Previous and Prior Year Date Values

How do I get the Previous, Prior year month and Prior year previous month values from a given date?
Ex: Input would be: 05/01/2008
The output should be:
05/01/2008 - Current Month
04/01/2008 - Previous Month for the Current Year
05/01/2007 - Prior year current Month
04/01/2007 - Prior Year Previous Month
Please let me know..

Hi,
Then you'll probably do a self-join. In one copy of the table, you'll get the data from date d1, and in the other copy, you'll get the data from date ADD_MONTHS (d1, -12).
If, ultimately, you are going to show four sets of figures (from four different rows representing four different dates) on the same output line, then you may find it more convenient to do a pivot rather than a self-join. Search for the buzz word "pivot" and you'll get lots of examples. You might start by selecting four rows:
WHERE   dt IN
        ( d1
        , ADD_MONTHS (d1, -1)
        , ADD_MONTHS (d1, -12)
        , ADD_MONTHS (d1, -13)
        ) ...and then pivoting that data into four columns:
SELECT  ...
,       MAX (CASE WHEN dt = d1                   THEN val END) AS this_month
,       MAX (CASE WHEN dt = ADD_MONTHS (d1, -1)  THEN val END) AS one_month_ago
,       MAX (CASE WHEN dt = ADD_MONTHS (d1, -12) THEN val END) AS one_year_ago
,       MAX (CASE WHEN dt = ADD_MONTHS (d1, -13) THEN val END) AS thirteen_months_ago
...

Similar Messages

  • Date Picker with Previous and Next Year Options

    Hi All,
    I am implementing a date picker in my application which is tied to an attribute of type PA0001-BEGDA. Date Picker as such works fine but navigating to previous year and Next year options are not available. User has to go month by month to different years if they have to navigate.
    Is this the normal behavior of the Date Picker or am I missing something else to get the previous and Next year icons in the Date Picker.
    Thanks,
    Nagarajan.

    hmm..I tried using the select options and it did give the same date picker with the previous and Next navigation icons...The only problem with the select options is that its a single field which has the range and can accept multiple values too...
    I tried to figure out how the date picker that we use in the custom application and the one in Select Options differ but no luck...Does this ring any bell?
    Thanks,
    Nagarajan.

  • CURRENT YEAR SALES DATE PARAMATER AND PRIOR YEAR SAME DATE RANGE

    I am pulling data from a SQL view dbo.view that has current and historical SOP data by line.  The date paramater is a date range,  uppr date and lower date formulas are in the report.  I need to include prior year SOP data for the same prior year date range in the detail.  I have tried adding the view in twice with no luck, just duplications.  Ultimately I want to supress the detail and only show the totals by customer so it is comparitive.  Thanks for your help.  Jayne

    OK
    lets simplify it
    get a test data source with some simple dates in it.
    get the report logic working.
    it looks like you have the right formula ideas but lets go for
    @upperthisyear
    @upperlastyear
    @lowerthisyear
    @lowerlastyear
    then assuming a date field of {table1.date}
    the record selection would be
    if (@upperthisyeare > {table1.date} and @lowerthisyear < {table1.date}) or (@upperlastyeare > {table1.date} and @lowerlastyear < {table1.date}) then 1 else 0
    I would test this by using it as a formula field with the test data.

  • Need to apply MTD logic for actual and prior year

    Hi Team,
    We are facing an issue with MTD calculation based on formula variables,
    Issue: MTD Only (Actual and Prior Year) – show the same value for MTD. 
    Requirement:
    When the query is run for a selected month, the query should be run for that month based on the Last TECO Date (Input Variable).
    • For example, dashboard is run for January 2014, the calculation of MTD should be based on the Last TECO Date : i.,e if I enter older date/month (not current date)[ 1/20/2014 means it should calculate for 1/1/2014 – 1/31/2014]
    • If the dashboard is run for the current month, the MTD calculation should be on Last TECO Date = 1st day of month – Current Day
    The above same calculation logic should be applicable for MTD prior year: instead of the input variable value, the value for previous year should be considered
    Final Calculation:
    If Last Labour Date is blank, 0, else Last TECO Date – Last Labour Date (by individual line item)
    Here we created two formula variables for last teco date and last labour date.
    Also created 2 Customer Exit variable for MTD Actual calculation.
    We have pulled the formula variable and CE variable into the selection and created a new CKF (Teco date).
    We have done the final calculation on the basis of the ( (labour date ==0)*0 + last teco date-last labour date )for MTD ACTUAL.
    MTD Prior Year-
    when have done calculation on the basis of the( (labour date ==0)*0 + last teco date-last labour date )for MTD Prior year by giving offset -12 to the value.
    Here for MTD Actual and MTD Prior year values are coming same  ,we tried with by doing customer exit variables as well, Still values are coming same.
    please give your valuable inputs/suggestions to proceed for this requirement .

    I assume the Sales measure is a monthly measure. The Prior year calculation as I described will give you the sales for the same month in the previous year when selecting month in your report. When selecting year it will add up all months of the prior year until now and you will indeed see the Prior year YTD.
    If you want to see the total sales for the previous year you have to use the same calculation as 'Prior year' and map it to the year level of your time dimension. This will work as a 'partition by year'.

  • How to use the Time Variants PYTD and Prior Year Annual?

    Hi,
    We have a time dimension which has the generic columns i.e Month, Year.
    We need to calculate the Time variants for the Facts Say Sales. I was able to calculate the Prior Month, Current YTD
    I have some doubts regarding the other variants:
    1. Prior Year : Does this include the Prior Year Annual?
    2. Prior YTD: How to calculate it?
    Somehow I am getting the same results for PYTD and Prior Year.
    The formula used are :
    Prior Year:
    AGO(Sales, Year, 1)
    PYTD:
    AGO(Sales CYTD, Year, 1)
    Has anybody encountered similar issue?

    I assume the Sales measure is a monthly measure. The Prior year calculation as I described will give you the sales for the same month in the previous year when selecting month in your report. When selecting year it will add up all months of the prior year until now and you will indeed see the Prior year YTD.
    If you want to see the total sales for the previous year you have to use the same calculation as 'Prior year' and map it to the year level of your time dimension. This will work as a 'partition by year'.

  • Copy config and payroll rules & shemas and 2 years data into ECC6 from 4.7

    Hi ,
    we need to copy config and payroll rules & shemas and 2 years data into ECC6 from 4.7 enterprise .
    Please let me now How to do it ?
    I will give points for suitable answers pl
    Thanks,
    Sunitha

    Hi Sonu Gupta,
    Can please explain bit more ...
    Config and Data both i wanted to move 4.7 sytem to ECC6 system . both are diffrent systems .
    what is this peace list ?How to create ?
    in case of Config how to trsnfer .
    Please Help Me ...
    Sunitha
    Edited by: Sunitha Reddy on Apr 10, 2008 3:34 PM

  • Displaying current and prior quarter data in FR

    Hi,
    I have two grids in report.Grid 1 and Grid 2.
    I have to display data for current quarter and current year in Grid1
    and Grid 2 should display data for prior quarter and year should change accordingly.
    Ex Grid1 : Q4 2008 Then Grid2: Q3 2008, this works by using relative period.
    But problem is when Grid1: Q1 2008, Grid2 should be: Q4 2007.
    How would this be possible?Can we use any formula or condition?
    Any idea would be appreciated.
    Thanks

    Of course it works, I tested on my environment, independently of what I have as accounts or anything else. If you want Grid2 to show the prior Quarter swap the values like this:
    Grid1 Column A: Current Point of View for Period
    Current Point of View for Year
    Grid2 Column A: Period Current Point of View for Period offset by -1
    Current Point of View for Year
    You dont need to worry about the Year, for it knows to go back based on the other parameters.
    If you select in your POV__________________________Year: 2008________________________Period: Q1
    You will get the following results:
    Grid2: Q4 2007
    Grid1: Q1 2008

  • Select Row immediately previous and following a date range

    I have a query which returns two values within a given date range (colA, colB). This works great. However, I also need to return (in a separate query) the entries immediately previous and following this current date range (same two values).
    I am more familiar with MySQL where the query would include an "Order by date desc limit 1" for the row previous to the original query or "Order by date asc limit 1" for the row following the original query.
    What is the best way to return these rows within Oracle?

    Hi,
    This is an example of a Top-N Query, where you want to pick N items (N=1 in this case) from the top of an ordered list.
    This problem is a little trickier, because you want to pick from two lists, the rows before the specieifed date range (in descending order) and the rows after the range.
    The easiest way might be a UNION of two separate queries, using WHERE ROWNUM = 1 in each one.
    The solution below is easier to generalize, e.g. if you want the first and last row from each department.
    WITH
    e     AS
         SELECT     empno, ename, hiredate
         ,     ROW_NUMBER () OVER
              ( ORDER BY     CASE
                             WHEN hiredate < TO_DATE ( '01-JAN-1982'
                                            , 'DD-MON-YYYY'
                                            ) -- Start of date range
                             THEN hiredate
                        END
                        DESC     NULLS LAST
              ) AS pre_num
         ,     ROW_NUMBER () OVER
              ( ORDER BY     CASE
                             WHEN hiredate > TO_DATE     ( '31-DEC-1982'
                                            , 'DD-MON-YYYY'
                                            ) -- End of date range
                             THEN hiredate
                        END
              ) AS post_num
         FROM     scott.emp
    SELECT     empno, ename, hiredate
    FROM     e
    WHERE     pre_num          = 1
    OR     post_num     = 1
    ;Results (last hire before 1982 and first hire after 1982):
         EMPNO ENAME      HIREDATE
          7788 SCOTT      19-APR-87
          7900 JAMES      03-DEC-81

  • Current Year and Previou year Data comparision - Urgent

    Hi Experts,
    In our report we need to compare the sales value for current year and prevous year.
    The Fiscal year is the input selection field.
    Output report displayed as below
    Product|Current year sales|Previous year sales|
    404    |120.00          |20.00
    400    |122.00          |22.00
    Total  |242.00          |42.00
    Could any body help how do i use the fiscal year/period or fiscal year for the current sales and previous sales values.
    Thanks in advance.
    Mahantesh

    You have to restricit current year column with the variable Fiscal year and previous year colum with same variable with offset -1.
    For year period use a range with from valie '001.1990' and to value a variable for current and the same variable with offset -12 for previous.
    Hope it helps.
    Regards

  • Report with Current and Prior Year

    I'm looking to create a report with fields Report Group, Year, and Actual Dollars.  Where the Year includes the current year and the prior year (NOT user input).  The format would be:
    Report Group | | Year | | Actual Dollars
    Product Revenue | | 2008 | | $100
    Product Revenue | | 2009 | | $200
    etc
    Sounds simple enough but I'm having difficulty getting it to work since I need the Year field in the report (and I'm new to WebI).
    Thanks for your help,
    Dave

    Hi David,
    I'd suggest you use a Query filter (or a report filter) to retrieve only rows that match this criteria on years. Since you need two values, I may have to use the filtering operator 'in list'
    Difference between those two is query filter will only retrieve to values where year = 2008 or 2009 from the datasource (so if you want to change the year values, you will have to refresh document), while report filters are active on the query output (which means that no refresh from the DB is required if you need to change values), which might bring a better experience if you need interactivity in the report. Moreover, if interactivity is important and you are working with WebI XI 3.1 SP2, you can embed these report filters into Input Control, and command the filter from a graphical widget like check boxes, to let user control which years he wants to view/ compare in the table (or chart).
    Hope that helps,
    David.

  • Does Lion work with Turbotax 2010 and prior years?

    Does the current year version of TurboTax work with Lion.  Also are there any "cut-off" prior year compatibility issues.  Intuit has not posted a confirmation on their website.

    Thanks baltwo.  I went to the Intuit discussion forum and found a tip which led to solving my specific problem discussed above.  I was able to resolve the problem by turning off the Resume function in TurboTax per the following link:
    http://osxdaily.com/2011/08/01/turn-off-resume-per-app-in-mac-os-x-lion/
    Specifically, I typed the following into Terminal:
    defaults write com.intuit.turbotax.2010 NSQuitAlwaysKeepsWindows -bool false
    I had to recover my original file from a backup, but now all is well with making changes, saving the file and reopening the file.

  • Trying to use the customer exit to retrieve prior year dates HELP

    i have the code below where i want to return a to & from date of the prior period.  the "TO" date is always the 1st of the month of the day they entered - 1 to get prior year.  when i debug they are populated but I get an error when i run the query sayin gthe enhancement has errors. 
    CASE I_VNAM.
      WHEN 'ZD_TOFROMDATEPRIOR'.
        IF i_step = 2.
          loop at  I_T_VAR_RANGE INTO Loc_Var_Range
          where vnam = 'ZD_DATEENTERED'.
            Clear L_S_Range.
            L_S_Range-low0(4) = Loc_Var_Range-low0(4) - 1.
            CONCATENATE L_S_Range-low0(4) loc_var_range-low4(2) '01' INTO L_S_RANGE-low.
       CONCATENATE L_S_Range-low0(4) loc_var_range-low4(2) loc_var_range-low+6(2) INTO l_s_range-high.
         l_s_range-high = loc_var_range-low+4(4).
            L_S_RANGE-sign = 'I'.
            L_S_RANGE-opt = 'BT'.
            APPEND L_S_Range TO E_T_RANGE.
          endloop.
        ENDIF.
    ENDCASE.

    In case you haven't considered it, there is an easier way to accomplish this.
    Since you are ignoring the day anyway, change your query to prompt for Calendar Month/Year or Fiscal Year/Period instead of prompting for a date range, then use variable offset of "-12" on first entry ("From") to get prior year's data.
    Alternatively, you could use the current date range variable with an offset of "-365", but it doesn't sound like that would be good enough in your case.
    Hope this helps...
    Bob

  • Add and/or subract data values in form fields

    I'm trying to have a date value in one field calculated from another. For example Issue date field plus 90 days = Contract Due data field. Is there a way, maybe javascript to do this in a ADD form?
    Thanks for any help,
    Tony

    Hi Tony,
    instead of trying that with javascript, I´d rather create a Custom Trigger
    (type: AFTER) which updates your table´s "contract_due" column by applying MySQL´s DATE_ADD function to ADDT´s transaction value
    ($tNG->getColumnValue("column_name")), like this:
    "UPDATE tablename SET contract_due = DATE_ADD(".$tNG->getColumnValue("issue_date").",INTERVAL 90 DAY) WHERE primary_key_column = ".$tNG->getPrimaryKeyValue()."";
    That should work, although I´m not sure if you would first have to convert the value of $tNG->getColumnValue("issue_date") back to a valid MySQL date format
    (YYYY-MM-DD), in case the field "issue_date" displays the date in a different format, like e.g. DD.MM.YYYY
    However I think that a javascript based approach should be avoided whenever possible, because even if that works, the user might modify the "contract_due" field value before submitting the data.
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Calc with Current and Prior Periods Data

    <p>Hi Everyone -<br><br>I would like to come up with two types of calculations usingamounts from prior periods (dynamically)<br><br>1. "Net Sales" (current period) + "Net Sales"(current period - 3 months) + "Net Sales" (current period- 6 months) + "Net Sales" (current period - 9 months)i.e. If current period = June ... Net Sales Amount in June + NetSales Amount in March + Net Sales Amount in December of the yearbefore + Net Sales Amount in September of the year before.<br><br>2. Sum "Cash" for the past 12 months (current period tocurrent period - 11)<br><br>In both cases, we'll need to handle getting amounts from the prioryear, as well.<br><br>I can feed the "current period" in thru a sub var, yet(assuming that is the correct function, I am not sure how to set up@PRIOR with Current Period - n Periods...<br><br>I appreciate your help. Grazie ...lb<br></p>

    Hi David,
    I'd suggest you use a Query filter (or a report filter) to retrieve only rows that match this criteria on years. Since you need two values, I may have to use the filtering operator 'in list'
    Difference between those two is query filter will only retrieve to values where year = 2008 or 2009 from the datasource (so if you want to change the year values, you will have to refresh document), while report filters are active on the query output (which means that no refresh from the DB is required if you need to change values), which might bring a better experience if you need interactivity in the report. Moreover, if interactivity is important and you are working with WebI XI 3.1 SP2, you can embed these report filters into Input Control, and command the filter from a graphical widget like check boxes, to let user control which years he wants to view/ compare in the table (or chart).
    Hope that helps,
    David.

  • How to Get Prior Year Month Value in Query

    I have a query requirement to get the Sales and Sales Previous Year in the result line for a Product.
    Calendar Month is also in the rows of the query.
    Example - I would need Sales for 10/2009 and Sales Previous Year for 10/2008.
    I'm using the variable CMONTH as an interval with offsets to get 24 months before and after the current month.
    How can I get Sales Previous Year on the same line as using variable offsets on 0CMONTH does not work as
    0CMONTH is always considered to be the current month ?

    Yes, I understand - sorry, I was thinking about 0calmonth2 or is it 3 ??, the one with just the month, not the year, being in the rows.... it will give you the breakdown by months for each column.
    if you want to be able to select on the months, create an interval variable on the 0calmonth2 like mentioned already - you wont need to offset on that one though, because you already got the offset on the year...
    regards
    jacob
    Edited by: Jacob Jansen on Oct 8, 2009 7:18 PM
    Edited by: Jacob Jansen on Oct 8, 2009 7:20 PM

Maybe you are looking for

  • Lengthy query

    Hi, when i am firing below mentioned query it takes more than an hour,but when i put inner join instead of left outer join it fetches immediately can someone explain me what this query says why it is taking some much time thanks SELECT TOTAL.product_

  • ITunes 8.2 crashing on Vista?

    I installed iTunes 8.2 a couple of days ago, and it crashed on first startup while it was updating the library (or whatever it was doing: I forget exactly what). I started it again, and it seemed to run ok. Just now I decided to back up the entire li

  • Purchase Order - Quantity Field printing.

    Hi Gurus. I am printing purchase orders via SAP script. My users want the quantity field (RM06P-PRMG1) to have a dot(.) not a comma(,) eg they want to print the number as 200.000 and not 200,000 Is there somewhere, i can switch this without adding an

  • Inbound Processing for cremas

    I am getting CREMAS idoc from SAP to my SAP system. When it comes to my system, i dont want that to create a new vendor number instead update or overwrite the exixiting vendoe number. Can anyone lemme know how i can do that

  • Can't get beyond the spinning beach ball when I open mail

    I am running 10.3.9 and when I launch Mail, it opens about a dozen different mail messages and the beach ball starts spinning. After a few force quits and disk utility repair permissions, I am stuck. Please help! Thanks! Brian