Display difference current week to prior week

Hi everyone,
I have following question. I need to display in a Report the difference from the current week to the prior week. I need something like this:
weeks       |      quantity      |    difference to prior week
30          |     1000           |
31          |      500           |     -500
32          |      800           |      300
33          |     1200           |      400
34          |     1000           |     -200
By starting the report the user enters the "start_date" and "end_date".
For this example the user enters from "19.07.2009" to "22.08.2009"
Do you have any ideas how to solve this?
Many thanks in advance
Mario

Hi Salah,
many thanks for your answer but this doesn't work on my side because each week is a summary of many different records from the database. If I work with "previous" it only subtracts the last quantity from the weeks summary, not the last weeks summary from this weeks summary.
Is it possible to change the formula to something like this:
sum ({quantity}, {@calendarweek} ) - previous (sum ({quantity}, {@calendarweek} )
something like this whould help me I think but I receive an error from the "previous" too much parameters
Now I tried to create a new formula like this:
@quantity_calenderweek
= sum ({quantity}, {@calendarweek} )
and used it with my previous formula:
{@quantity_calenderweek} - previous ({@quantity_calenderweek})
but now crystal sais that this field hast no prior or following value...

Similar Messages

  • HT3281 Podcasts from Current Tv, since three weeks prior to the Nov 2012 election have had a url problem and cannot be played on my mac mini 2011 with 10.8.2 and the latest Itunes? anyone know why ? I am in contact with Itunes now and they wanted screensh

    Podcasts from Current Tv, since three weeks prior to the Nov 2012 election have had a url problem and cannot be played on my mac mini 2011 with 10.8.2 and the latest Itunes? anyone know why> ? I am in contact with Itunes now and they wanted screenshots of the problem, I can get these current tv episodes with a vpn and my isp says they are not blocking them, but i was surprised that prior to the election they were blocked, ?
    I also can get them on my Android Samsung Galaxy note 2 with no problem but on the Macmini cannot>/? I Unsubscribed and subscribed many times but still no luck, any ideas? I am waiting for the senior advisor to get back to me on this issue. I am in THailand now where the problem is happening and as I said the ISP says they do not block any podcasts.I also do not want it on my iphone 5, so I have to wait and see why the mac mini is not getting it.

    I seem to have fixed it by putting <div  class="clearfloat"></div> after the navigation bar?

  • Display only current week events in sharepoint web part calendar

    i am using calendar in webpart. i need to display only current week events in calendar. Please give me any suggestions...
    Thanks Manohara R

    You could do this using calculated field formula. Refer to the following posts for more information
    http://modery.net/showing-only-this-weeks-events-of-a-sharepoint-calendar/
    http://ankursharepoint.wordpress.com/2011/01/19/list-filter-current-week-items-only/
    http://abstractspaces.wordpress.com/2008/05/14/filter-list-view-by-current-week/
    --Cheers

  • Average quantity for Prior weeks

    Hello Friends,
    I have a requirement to calculate prior 4 weeks quantity average and price average.
    And also I have to calculate price variance by substracting current weeks price with previous weeks price.
    I have price and quantity are in KF, and calyear/week in free characteristcis.
    Can you please help me?
    Thanks
    Priya

    Hi,
    I have followed below suggestions and it didn't give me any results.
    Currently, I have 3 KF, quantity, price and total price.and Calweek/year which is restricted to current calweek and previous week in KF section.
    And it displays results like this, and which is what I wanted.
    07.2007                    06.2007           
    Quantity Price Total Price   Quantity     Price     Total Price
    In addtion to this results, I have to display prior 4 weeks average of Quantity,Price and total price.
    These are the steps I have followed:
    Created a structure, 4 new selections for four prior weeks, with offsets on calyear/week till -4, by having quantity in the selection. I am not able to do the formula as price and quantity doesn't appear for those four columns I have created for prior weeks.
    I appreciate your help .
    Thanks
    Priya.

  • How to get data for current week and previous week using customer exit in Bex.

    Hi everyone,
    I have a scenario in which I need to display data for current week and previous week (based on "sy_datum" the program has to calculate current week and previous week) in Bex using  Customer exit. I have created one variable in Bex Query Designer and I have written code for the variable in CMOD. But it is not working fine, (I know that we can do the same by using offset value in Bex). Can some one guide me how to achieve my requirement using customer exit.
    Thanks in Advance,
    G S Ramanjaneyulu.

    Hi krishna,
    Thanks for your quick reply, can you have a look at my code,
    case i_vnam.
    WHEN 'ZPWK_CWK'.
    ranges : pre_week for sy-datum.
    data : start_date type DATS,
           end_date TYPE dats .
    ************FM TO GET FIRST DATE OF CURRENT WEEK ************************
    CALL FUNCTION 'BWSO_DATE_GET_FIRST_WEEKDAY'
      EXPORTING
        DATE_IN  = sy-datum
      IMPORTING
        DATE_OUT = start_date.   " WEEK FIRST DATE
    end_date = START_DATE + 6.   " WEEK LAST DATE
    END_DATE   = START_DATE - 1.   " PREVIOUS WEEK END DATE
    START_DATE = START_DATE - 7.   " PREVIOUS WEEK START  DATE
    **********PREVIOUS WEEK DATES IN PRE_WEEK******************
    pre_week-SIGN   = 'I'.
    pre_week-option = 'BT'.
    pre_week-LOW    = START_DATE.
    pre_week-HIGH   = END_DATE.
    APPEND  pre_week.
    CLEAR : START_DATE,END_DATE.
    endcase.
    Regards,
    G S Ramanjaneyulu.

  • Report Issue: Previous Weeks, Current Week and Next Week Values

    Hello Folks,
    this is a typical requirement...at-least typical for me..
    we have 20 weeks of data at weekly level. we have four Metrics out of which two are coming from Database and rest two are calculated metrics.
    Metric0: On Hand Qty
    Metric1: Past Qty
    Metric2: sell Qty
    Metric3: unsell qty
    Metric4: Total Qty
    the report will always be shown for 20 weeks, but depending on whats my current week, all the past weeks should be flagged as Past Week. (so i wrote a case statement for this). for Instance: I am in Week11, so my weeks in should be Past Week, Wk11, Wk12.........Wk20.
    Metric 1 is always dependent on result of Metric4 (This is the Complexity) per week basis
    Metric1 for Past weeks value in Week Column will be wk1 to wk10 On Hand Qty (fox ex: 80)
    Metric4 for Pass Weeks Value in Week Column will be Metric1 for Pastweeks + Metric2 for Past Weeks (For Ex: 20) (Past weeks mean wk1 to wk10)
    value of Metric4 is now 100
    Metric1 for Week11 Now should 100 (From Past weeks Calculation)
    Metric4 for Week11 will be Metric1 for Week11(100) + Metric2 for Week11(10) + Metric3 for Week11 (10)
    Now...Metric1 for Week12 will be 120 which is wk11 total (100+10+10) and goes on Until Week 20
    Any Ideas how to achieve this in obiee 10g
    Thanks
    Rake

    Please try out in this way....
    Database level --Create opaque view & procedure or function  to get the week total,week ago total, current week , Past week ,future week & do rpd modelling and use PIVOT VIEW.
    At answers:
    1.Here Previous week M4 is the current week M1 which means it is a cumulative value carried forward week by week.
    2. M2 & M3 are direct database columns.
    3. You have time hierarchy with WEEK Level.
    M1 - ago(rsum(m2+m3),weeklevel)
    M4- RSUM(M2+M3)
    week -AGO(RSUM(M2+M3)- M2-M3-RSUM(M2+M3)
    w1-0-10-20-30
    w2-30-11-21-62
    w3-62-12-22-96
    Now you can PIVOT IT to get in
    W1-W2-W3
    M1 0 - 30-62
    M2 10-11-12
    M3 20 -21-22
    M4 30 - 62-96
    NOW PASTWEEK (W1-W10), CURRENT WEEK(W11)-W12
    1.as you see cumulative here you need to use BINS.means ( case when week <= currentweek(maybe variable) then prior) else week)
    2. UNION - combine similar request - First cirteria week <= w11 and second criteria week > week 11 --combine pivot it. Use sum agg in fx criteria1.
    Hope this should solve your pblm at answers.
    Edited by: MK on Oct 27, 2011 12:48 PM

  • Rollover 18 weeks starting from week number of current month

    Hi,
    I have a requirement as described below.
    Table Name Time:
    Columns: Fiscal Year, Fiscal Month and Fiscal Week
    above table has join with sales table and it contain sales data on week basis. so least granularity of data at week level.
    we have a report with columns fiscal year, actual sales and forcast sales. our requirement is to filter the data with following criteria.
    Current Month Filter
    Jan fiscal week between 1-18 of current year
    Feb fiscal week between 5-23 of current year
    March fiscal week between 9-27 of current year
    November fiscal week between week 44 of current year and week 10 of next year
    December
    so with above requirement we need to filter data with rollover 18 weeks starting from week number of current month
    I tried with timestampadd(sql_tsi_week, interval, week) but it's not working as I expacting. Please provide the code/logic to get it done.
    Appreciate your help.
    Thanks
    Jay.

    Jay wrote:
    I need to get rollover 18 week data at anypoint of time starting with week number of 1st of every month to 18 weeks. read my question again and you will be able to understand.You're kind of missing the point to be honest. It's very hard to answer specific questions without the required information. To answer a question like this we need a minimum of:
    1. Oracle version
    2. Sample data (CREATE TABLE / INSERT statements)
    3. Expected output
    4. Explanation of business rules.
    Alternatively, you can read the link in my original response.
    Please provide the required information and someone can help.

  • Defining "prior-week" timeframe dynamically for scheduled reports

    I have a number of reports that I need to execute each week.  But, the scheduling options don't allow me to kick off the report on a Sunday AND constrain the timeframe to the prior week (Sunday-Saturday).   I have a prompt built into the original query, but that's useless if I want to automate the output. 
    I was successful getting the query to work against the upstream database using the following query fragment:
    BETWEEN CURRENT_DATE - INTERVAL '7 day' AND CURRENT_DATE - INTERVAL '1 day'
    But, there is no option to enter this query into the BI.Ondemand UI. 
    Any insight would be helpful.   This issue is hindering progress with our metrics automation plans.
    Regards,
    -Joe

    I'm using the Web-based version of BI.ondemand.  
    I don't have access to the OnDemand Desktop Publisher because the hosting provider I'm using doesn't support it.  
    The scheduler is very unstable in the web version. I often get "page not loaded" errors in the prompt window within the popup scheduler.  
    I've also just determined that the week-definition in BObj is Monday-Sunday and not Sunday-Saturday.   I'd need to make that adjustment as well. 
    --Joe

  • CATS: Batch changes for prior week's records

    We have requirements to develop a custom application that will address what we call "Labor Cost Transfers" (LCT).   The customer does not allow employees to manually change their time in CATS for prior weeks.  Instead, they must submit an LCT request (via email) to a centralized admin group who then manually makes the change in CATS.  The new Web Dynpro application will automate requesting, approving (two levels) and reporting of these LCTs.  A new batch program will be developed using traditional ABAP to process these approved requests and update CATSDB - probably on  a weekly basis.  
    On the request screen, the user will enter selection criteria (e.g. PERNR, W.E. Date, Receiver Cost Object) to identify the CATSDB data that needs to be changed.  The application will present the data in rows like the CAT2 time sheet with a Saturday thru Friday view.  The user will select the "FROM" (BEFORE) row to be changed and enter their "TO" (AFTER) data in the "TO" section below - again like the CAT2 time sheet view.
    The planned design includes two new custom (Z) tables...one to hold the FROM data and the other to hold the TO data.  The FROM table is sort of like a header table that will contain the CATS data values before the change as well as the admin data associated with the request (requester, approver, status, dates, etc.).  The TO table has the CATSDB values that the requester wants the record(s) changed to.
    This application will only allow the user to transfer hours from one receiver cost object to another for the same A/A type.  (In other words, they cannot move hours from one A/A type to another).  This means their change will not impact payroll.  (Such payroll adjustments will be addressed in a future project).
    I'm giving this background information so that I can ask a few general questions - that may lead to more if I can any responses.
    Questions:
    1)  Have any of you developers been involved - or know of - similar custom applications?  If so, what approach was taken?
    2)  Because the LCT request data is at the time sheet row level and the batch update program must update at the CATSDB record level, I'm thinking that I will have to use the DELETE and the INSERT BAPIs rather than the CHANGE.  Do you agree?
    3)  Do you find it strange that the customer will not allow employees to change their time sheets for any prior periods?  How far back can employees change their CATS data at your site?
    Any feedback will be greatly appreciated.  
    Ralph

    ktallman wrote:
    Sorry. Here's the link to the similar post (with the Apple Script): http://discussions.apple.com/thread.jspa?messageID=8001104&#8001104
    that apple script is actually mine, lol.
    I actually added 4 custom fields in the address book, to align to the 4 from the Treo, but I see that they don't map to the iPhone. There is a date field on the iPhone for when we met, which is one of my custom fields, but I don't see a corresponding field in the Address Book.
    Yes, I would like to substitute one string for another ("X-Palm-Custom3" to "Directions") everywhere it occurs in the Notes field.
    ok, the following apple script will do it.
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #ADD8E6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    tell application "Address Book"
    repeat with per in people
    set x to note of per as text
    if x is not equal to "missing value" then
    set note of per to do shell script "echo " & quoted form of x & "|sed 's/X-Palm-Custom3/Directions/g'"
    end if
    end repeat
    end tell</pre>
    Paste it into Script Editor and hit "run".
    Thanks.
    Ken

  • How to display the current date in Flex app

    I need to display the current date in my Flex application.  Is there a simple way to do this and display it as a label or text field?  Also, can this be formatted to display the date as "Day of Week, Month Day, Year"?
    Thanks!

    You can use this code and this page to tweak the formatString property.
    http://livedocs.adobe.com/flex/3/langref/mx/formatters/DateFormatter.html#formatString
    If this post answers your question or helps, please mark it as such.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
      creationComplete="init();">
      <mx:Script>
        <![CDATA[
          [Bindable] private var date:String;
          private function init():void{
            date = new Date().toString();
            date = df.format(date);
        ]]>
      </mx:Script>
      <mx:DateFormatter id="df" formatString="EEEE, MMMM D, YYYY"/>
      <mx:Label text="{date}"/>
    </mx:Application>

  • How can you tell between Week 37 and Week 38?

    Hey everyone. Well it took me some research to find out the difference between week 37 and week 38.
    So to clear up with future readers that arent sure, The "week" refers to when the ipod was made.
    Anyways, is their a visual difference on the box display? I know you can tell by looking at the serial but im nervous with targets "no return if opened" policy.
    And if I did open it, would a warranty (I would buy seperatly) cover that if their were problems?

    The week 38 box has Macy Gray on the front.  I do not remember who week 36/37 was, but some week 37's had Macy Gray on their box as well.  So, the ONLY way to know for sure if you have a week #38 is to look at the "SERIAL NUMBER IS LOCATED ON THE BACK OF THE BOX"!  You DO NOT have to open the box to see the serial number!  So that should resolve Targets issue.
    NOTE~~~~ Apple has released a firmware update 1.1.1, which appears to have resolved the screen problems that plagued week 37.  However, if you are buying NEW, don't mess around and get a 38!
    Gunny

  • Last week, last 2 weeks, last 4 weeks

    Hi, I want to calculate # of opportunities in the last week, last 2 weeks, last 4 weeks, last 8 weeks, last 12 weeks. What would be the best way to do in terms of simplicity and performance.
    thx,
    parag

    Hi,
    yea you still need time dimension table to achieve this.The filter function (improves performance) he is talking about is if you go to BMM layer and any column you find expression builder in that this function can be found under Functions > Display Functions > Filter and use it accordingly.
    Achieving last 2 weeks ,3 weeks you need to write logic necessary according to your requirement.
    UPDATED POST
    In BMM logical column properties-->check use logical column as the source from there go to expression builder and select in left most pane Functions/Display Functions/Filter function
    I found some blogs this might help you go to next step using week_of_year http://gerardnico.com/wiki/dat/obiee/date
    How to get week of the current month
    Cheers,
    KK
    Edited by: Kranthi.K on Mar 23, 2011 2:11 AM

  • Sunday 17-Jan-2010: In week 2 or week 3? Does Apple use ISO week dates?

    According to Wikipedia, http://en.wikipedia.org/wiki/ISOweekdate "All week-numbering years start with a Monday and end with a Sunday."
    http://personal.ecu.edu/mccartyr/isowdcal.html shows this too.
    However, my MBP running 10.5.8. shows today, Sun 17 Jan 2010 as week 3.
    This can be seen quickly by, following http://lifehacker.com/316029/display-the-date-on-the-menubar and dragging the Week of Year into the clock time shown on the menu bar, and viewing it on a Sunday.
    Or does Apple not follow the ISO week date numbering standard?
    Thanks,
    Martin.

    red_menace wrote:
    Actually, Apple does use (or is supposedly using) ISO 8601, but the System Preferences settings can override some of these, such as the region, calendar, or first day of the week.
    Actually, I think it is still an open question. According to Apple developer documentation:
    NSISO8601Calendar Identifier for the ISO8601. The ISO8601 calendar is not yet implemented.
    It does look like some of the conversions are a bit off, even in Snow Leopard, unless there is something I'm missing, too. Changing the date format (week starts with Monday) in System Preferences shows the correct week there (2), but getting the date from AppleScript, for example, shows week 3.
    I played around with my system preferences and could change the week start day, but I could never get an ISO 8601 date. Today (Sun, Jan 17th, 2010), I get either week 4 (Sunday) or week 3 (Monday).
    Clearly there are lots of date and time APIs to choose from and many of them on MacOS X already support this format. They haven't made it to the official system preferences level. Considering all the other calendar formats that Apple supports, I think this is a bug and mostly reflects MacOS X's American heritage. Americans don't use this value at all and don't even know to add it to a locale option.
    I filed a bug report on it. Don't hold your breath for it getting fixed anytime soon. In the meantime, here is a widget that will display the current week number: http://www.apple.com/downloads/dashboard/status/weeknumber_ntnu.html

  • Queries for current Qtr and prior quarter

    If I select one date in dashboard prompt in one column I want to display current quarter revenue and prior Qtr revenue.
    Could anyone give me the queries for the current Qtr and prior Qtr?
    So I will going to use presentation variable from the dashboard prompts

    obiee-date-expressions-reference
    Date Calculation OBIEE Expression Explanation :
    First Day of the Previous Year
    TIMESTAMPADD( SQL_TSI_YEAR , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD removes a year from the returned date for the First Day of the Previous Year.
    First Day of the Current Year
    TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE) This calculation returns the first day of the year by deducting one less than the total number of days in the year.
    First Day of the Next Year
    TIMESTAMPADD( SQL_TSI_YEAR , 1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD adds a year to the date returned which will give the first day of the next year.
    First Day of the Previous Month
    TIMESTAMPADD(SQL_TSI_MONTH, -1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) From right to left the first TIMESTAMPADD returns the first day of the Current Month. The second TIMESTAMPADD then subtracts one month from the first day of the Current Month arriving to the First Day of the previous month.
    First Day of the Current Month
    TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE) This expression gets the current day of the month and subtracts one less than the current day to arrive at the first day of the month.
    First Day of the Next Month
    TIMESTAMPADD(SQL_TSI_MONTH, 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) From right to left the first TIMESTAMPADD returns the first day of the Current Month. The second TIMESTAMPADD then adds one month from the first day of the Current Month arriving to the First Day of the next month.
    First Day of Current Quarter
    TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE) This was included to show the calculations discussed above can be used with other functions. This is the same expression as the one that returns the first day of the current month except this one uses the DAY_OF_QUARTER property to return the first day of the current quarter.
    Last Day of the Previous Month
    TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) From right to left the first TIMESTAMPADD returns the first day of the Current Month. The second TIMESTAMPADD subtracts a month to arrive at the first day of the previous month.
    Last Day of Current Month
    TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) From right to left the first TIMESTAMPADD finds the first day of the current Month. The second TIMESTAMPADD adds one month to the date to arrive at the first day of the next month. The final TIMESTAMPADD subtracts one day from the returned date to arrive at the last day of the Current Month.
    Last Day of the Next Month
    TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 2, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) From right to left the first TIMESTAMPADD finds the first day of the current Month. The second TIMESTAMPADD adds two months to the date to arrive at the first day of month after next. The final TIMESTAMPADD subtracts one day from the returned date to arrive at the last day of the Next Month.
    Last Day of Previous Year
    TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1,
    CURRENT_DATE)) From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD subtracts one day to arrive at December 31st of the previous year.
    Last Day of Current Year
    TIMESTAMPADD(SQL_TSI_YEAR, 1, TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD deducts one day to arrive at December 31 of the previous year. The third TIMESTAMPADD adds a single year to the date to arrive at December 31 of the Current Year.
    Last Day of the Next Year
    TIMESTAMPADD(SQL_TSI_YEAR, 2, TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) From right to left the first TIMESTAMPADD returns the first day of the current year. The second TIMESTAMPADD deducts one day to arrive at December 31 of the previous year. The third TIMESTAMPADD adds 2 years to the date to arrive at December 31 of the Next Year.
    Last Day of Current Quarter
    TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_QUARTER , 1, TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))) Demonstrated using Quarters. From right to left the first TIMESTAMPADD returns the first day of the Current Quarter. The second TIMESTAMPADD returns the first day of the next quarter. The final TIMESTAMPADD subtracts a single day from the date to arrive at the last day of the Current Quarter.
    Number of days between First Day of Year and Last Day of Current Month TIMESTAMPDIFF(SQL_TSI_DAY, CAST('2010/01/01 00:00:00' AS DATE), TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))) For simplicity I hard coded the January 1, 2010 date and CAST it to a date. I could have used the First Day of the Current Year calculation but didn’t want to over clutter the example. The second part of the TIMESTAMPDIFF uses Last Day of the Current Month calculation to force the TIMESTAMPDIFF to calculate the number of days between the first day of the year and the last day of the current month.
    =============
    FYI, let say some example,
    Last day of previous Quarter:
    "GPC_DataMart"."GPC_DataMart"."dbo"."LQ_Position"."Business_Date"=TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( "GPC_DataMart"."GPC_DataMart"."dbo"."MT_BUSINESS_DATE"."Business_Date") * -(1) + 1, "GPC_DataMart"."GPC_DataMart"."dbo"."MT_BUSINESS_DATE"."Business_Date"))
    Last month last day:
    "GPC_DataMart"."GPC_DataMart"."dbo"."LM_Position"."Business_Date"=
    TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( "GPC_DataMart"."GPC_DataMart"."dbo"."MT_BUSINESS_DATE"."Business_Date") * -(1) + 1, "GPC_DataMart"."GPC_DataMart"."dbo"."MT_BUSINESS_DATE"."Business_Date"))
    Last year Last day
    "GPC_DataMart"."GPC_DataMart"."dbo"."LY_Position"."Business_Date"=
    TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM "GPC_DataMart"."GPC_DataMart"."dbo"."MT_BUSINESS_DATE"."Business_Date") * -(1) + 1, "GPC_DataMart"."GPC_DataMart"."dbo"."MT_BUSINESS_DATE"."Business_Date"))
    Thanks and Regards,
    Deva
    http://obieeelegant.blogspot.com/2011/06/obiee-date-expressions-reference.html

  • Calendar Year/week 2014 53rd week

    Hi Experts,
    I have a BEx query that users use for comparison between previous and current Months, between previous and current Year and previous and current week of the year.
    In 2013 we have 52 weeks but in 2014 we have 53 weeks
    Users want to compare sales on weekly basis based on previous years and the current year but 53rd week on 2014 year is messing up the numbers.
    is it possible to exclude or include this 53rd week from the query by using some kind of filter or variable.
    Can you please help me the step by step process on how I can achieve this..
    Also please advise if I use this BEx query as a source for BOBJ webi query, is it easy to achieve this task in webi and How ?
    Will appreciate your help.
    Regards

    Hi Imran,
    I wonder is it really the correct thing to exclude a week of your sales?
    Do you want to compare week 10 this year V's week 10 last year - if so you can change your offset to -53 instead of -52.
    We use a lot of Customer Exits on time, and where we derive MTD values, we make allowances in the code for 53 week years.  Typically we add the extra week into August (different companies will make different decisions) so in August for last year our week numbers would be 31-34 and this year would be 31-35.  Sept last year would be 35-39 and this year 36-40  and so on.
    With regards
    Gill

Maybe you are looking for