Calculate Dates for Last week and next three weeks

Hi,
I have a report where I need to calculate dates between last week and the next three weeks (not counting current week). I'm familar with the first part, it could be done by using the LastFullweek function but not sure how I can avoid the current week and calculate the next three weeks.
Any help is greatly appreciated.
Thanks!

... and here are a few more...
Last Week...
IF {TableName.Date} IN
DateAdd("ww", DateDiff("ww", #1/7/1900#, CurrentDate), #1/7/1900#)
To
DateAdd("ww", DateDiff("ww", #1/7/1900#, CurrentDate) -1, #1/7/1900#)
THEN TRUE ELSE FALSE
The week before...
IF {TableName.Date} IN
DateAdd("ww", DateDiff("ww", #1/7/1900#, CurrentDate) -1, #1/7/1900#)
To
DateAdd("ww", DateDiff("ww", #1/7/1900#, CurrentDate) -2, #1/7/1900#)
THEN TRUE ELSE FALSE
And the week before that...
IF {TableName.Date} IN
DateAdd("ww", DateDiff("ww", #1/7/1900#, CurrentDate) -2, #1/7/1900#)
To
DateAdd("ww", DateDiff("ww", #1/7/1900#, CurrentDate) -3, #1/7/1900#)
THEN TRUE ELSE FALSE
and of course all 3 weeks together...
IF {TableName.Date} IN
DateAdd("ww", DateDiff("ww", #1/7/1900#, CurrentDate), #1/7/1900#)
To
DateAdd("ww", DateDiff("ww", #1/7/1900#, CurrentDate) -3, #1/7/1900#)
THEN TRUE ELSE FALSE
If you want the 1st day of the week to be Monday instead of Sunday just change the date of #1/7/190# to #1/1/1900#
HTH,
Jason

Similar Messages

  • 'Data for last import/Statistics' tab missing for Distributed imports in EMIGALL

    Hi experts,
    For some reason when I initiate Distributed loads using 'Distributed imports' in EMIGALL, I do not get the third and fourth tabs viz. 'Data for last import' and 'Statistics for import runs' after the loads are triggered. Is there a specific Note that needs to be applied. I checked Notes like 1179843, 780996 however they were relevant for previous releases and I am currently on release 605. Any insights to this problem?
    Thanks,
    Caroline.

    SharedObjects does the trick nicely!

  • How to get the data for last 3rd business day and also include saturday and sunday if its a wednesday?

    Hi All,
    I have a simple query which is below:-
    Declare @reportdate date
    set @reportdate= (DATEADD(dd,-5,getdate()))
    select * from dbo.Table
    where date IN (@reportdate)
    I need this query to pull the data for the last 3rd business day .So lets say today is monday then i need the data for last week wednesday which is 3 business days back from monday, if today is a tuesday it would be for last thursday ( as 3 business days for
    tuesday would be thursday). But if today is wednesday then i need to be last 3rd business day which is last friday and i also need to get the data for saturday and sunday.
    Can someone please help me how cani change my filter to do this?
    Please let me know if i am still unclear.
    Thanks

    Hi SqlDev12,
    Based on my understanding on your requirement, you can reference the below sample.
    CREATE TABLE BusinessTable
    Bdate DATE,
    Wd VARCHAR(10)
    ;WITH Cte(DT,WD) AS
    SELECT CAST('20150401' AS DATE),DATENAME(WEEKDAY,CAST('20150401' AS DATE))
    UNION ALL
    SELECT DATEADD(DAY,1,DT),DATENAME(WEEKDAY,DATEADD(DAY,1,DT)) FROM Cte
    WHERE DT<GETDATE()
    INSERT INTO BusinessTable SELECT * FROM Cte
    SELECT * FROM BusinessTable
    SET DATEFIRST 7 -- Set Sunday as the first day of a week
    DECLARE @givenDay DATE ='20150415' --Wednesday
    SELECT * FROM BusinessTable
    WHERE Bdate BETWEEN
    --For Monday and Sunday, select last wednesday
    (CASE WHEN DATEPART(WEEKDAY,@givenDay) IN(1,2) THEN DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay)-1,0))
    --For Tuesday and Wednesday, last week's Thursday and Friday
    WHEN DATEPART(WEEKDAY,@givenDay) IN(3,4) THEN DATEADD(DAY,-5,@givenDay)
    --For Thursday and Friday, current week's Monday and Tuesday
    WHEN DATEPART(WEEKDAY,@givenDay) IN(5,6) THEN DATEADD(DAY,-3,@givenDay)
    --For Saturday, current week's Wednesday
    ELSE DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay),0)) END)
    AND
    (CASE WHEN DATEPART(WEEKDAY,@givenDay) IN(1,2) THEN DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay)-1,0))
    WHEN DATEPART(WEEKDAY,@givenDay) IN(3) THEN DATEADD(DAY,-5,@givenDay)
    WHEN DATEPART(WEEKDAY,@givenDay) IN(4) THEN DATEADD(DAY,-3,@givenDay)
    WHEN DATEPART(WEEKDAY,@givenDay) IN(5,6) THEN DATEADD(DAY,-3,@givenDay)
    ELSE DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay),0)) END)
    DROP TABLE BusinessTable
    If you have any feedback on our support, you can click
    here.
    Eric Zhang
    TechNet Community Support

  • How to get Current week and No of Weeks for each quarter!!

    Hi,
    As a part of report development I have to derive Current week and No.of Weeks in Curreny Query. Based on these information I have to calculate Phased target (Calculated KYF).
    Phased target = (Target for Quarter / No of weeks in Current Quarter) X Current Week.
    We have to derive Current Quarter and Current week from  Customer Exit (From Invoice date, which is an entry by Users at report level).
    My questions are:
    1) We have to derive Two Restricted key figures (by Calweek)  for derving No of weeks for Currnet Quarter and Current week in Query level. Based on this info, we have to derive Calculated kef figure for Phased target.
    2) And the output is 6 (ex:- 132008) char length for Current week and we have to pick Week info only and we have to populate RKF created for Current week. How we can achieve this.
    3) Regarding the No of weeks per for current quarter, we are writing Customer exit to determine Quarter and no of weeks, but how to bring this info in query level.
    4) Is there any standard code available (SAP Exit) to find Current week and No of Weeks in Current quarter.
    Regards,
    Suresh Molli

    Hi Venkat Molli,
    Follow the below step for the doing the same:
    1. Create a customer exit variable on calweek.
    2. Restrict the created variable for respective info object.
    3. To Populate the data write code in CMOD.
         in enhancement function module: EXIT_SAPLRRS0_001 -> in Include ZXRSRU01 write the below code:
    WHEN '<variable name>'.
         IF i_step = 1.
          CLEAR l_s_range.
          CALL FUNCTION 'RSVAREXIT_0P_CWEEK'
            IMPORTING
              e_t_range = lt_week.
          READ TABLE lt_week INTO l_s_range1 INDEX 1.
          v_last_week = l_s_range1-low+4(2).
          v_last_week =  v_last_week - 1.
          l_s_range1-low+4(2) = v_last_week.
          l_s_range-low      =  l_s_range1-low.
          l_s_range-sign     = 'I'.
          l_s_range-opt      = 'EQ'.
          APPEND l_s_range TO e_t_range.
        ENDIF.
    4. Execute the report.
    I hope you can handle you issue now.
    Assign points if it is helpful.
    Regards,
    S P.

  • Calculate sales for last 60 days

    hello
    want to make key figure or formula, which calculate sales for last 60 days, but also i need to add week group in report, so for each week i need sum sales for last 60 days before this ...
    is any solution to that?
    thank you.

    Alex,
    I'm not very clear on what you are asking.
    If you use your time parameters in selections you can use caldays and weeks with your key figures.
    ie. Selection 1 has your key figure and calday restricted t the last 60 days.
    Selection 2 has your key figure and Fiscal Week but I am not clear on the range required for fiscal week.
    Regards
    Gill

  • How to populate data for 2LIS_40_REVAL, 2LIS_43_POSCAS and 2LIS_44_POSREC

    Hi
    How to populate data for 2LIS_40_REVAL, 2LIS_43_POSCAS and 2LIS_44_POSREC datasources at RSA3?
    I'm very new to retail BI.
    I think there is no setup tables for Retail infosources.
    Any IDoc or BAPI activation is required or other procedure?
    We are in BI-700 SAPKW70015 support pack R/3 side
    and SAP_BW 700 Support pack SAPKW70016 &
    BI_CONT 703 Support pack SAPKIBIIP9 BI side
    Can anyone guide me how to load data?
    Points assured
    Thanks in advance
    Ramana P

    Dear Ramana,
    There is no setup table for POSCAS and POSREC.This has to be popuated with a BADI Implementation. 
    As of PlugIns 2002_1_470 and 2002_2_470, POS data is update into BW the 2LIS_44_POSREC and 2LIS_43_POSCAS extractors using a BADI. To be able to update data into BW, the relevant implementation for the BADI must be activated in each case. You can activate the implementation in transaction SE19. The implementations are as follows:
    POS_EX_REC_PI2003_1 for extractor 2LIS_44_POSREC
    POS_EX_CAS_PI2003_1 for extractor 2LIS_44_POSCAS
    Once the activation of BADI , create the back ground jobs for the 44 application and the data is pushed into Delta queue and it can be loaded into BI .
    Hope this helps you.
    Thanks,
    Krishna Charan

  • Difference between Due Date for All Tasks and Duration per task in an approval workflow

    Hello,
    I'm starting to read up and learn about approval workflows in Designer 2010.  I am confused by the fields "Due Date for all Tasks" and the "Duration per task".  I understand that the Due date for all Tasks is the date that all
    of the tasks in the workflow must be completed by.  And I understand that the duration means each task has x number of days to complete.
    But I dont know whey we need them both.  If I have the task duration set to two days and there are 3 tasks involved, then wouldn't the due date be 6 days from the start?  Why would I have a due date for all tasks that is completely different than
    the sum of the duration of days for each task? 
    Please help shed some light!

    Hi Michelle,
    Due date for all tasks, this setting specifies the date by which all tasks are due. It’s used for serial and parallel
    task.
    Duration per tasks, this setting specifies the date by which an individual
     task is due, it’s used for serial workflow participants.
    Note, when you create an approval workflow, select task process participants(approvers oob approval workflow), we can also
    select once at a time(serial) or all at once(parallel).
    For more information, see
    http://office.microsoft.com/en-us/sharepoint-server-help/use-an-approval-workflow-HA101793831.aspx
    Best Regards.
    Kelly Chen
    TechNet Community Support

  • I must find my find my iphone data for last 1 year please help me

    i must find my find my iphone data for last 1 year please help me

    I confirmed, I have turned on " find my iphone. Here is the error I encountered

  • VF01 Determine Billing date for billing index and printout to current date

    Hi
    we need to determine the Billing date for billing index and printout to current date
    What can I do to determine automatically at the time of creation current day to Billing date for billing index and printout?
    please let me know
    Best Regards,

    Hi Beatriz ,
    You have two options here. you can chose either of these solutions:
    1.
    A. T-Code: VTFL ( if using del related billing)   For the billing document and delivery, at item level assign the copying requirement 011 or if you are currently using some other routine then you can use following in that
    VBRK-FKDAT = SY-DATUM.
    B. T-code VTFA (if using order related billing)
    Similar to A, using copying requirement 011.
    2. You may also try option of Checking in the User Exit for the Program RV60AFZA & RV60AFZA.
    Please let us know if this helps
    Regards
    Harpreet

  • Bapi - upload data for infotypes 0016 and 0019

    hello,
    Please let me know bapi to upload data for infotypes 0016 and 0019 as i am unable to find any bapi for this infotypes.
    Please use a more meaningful subject in future - I've edited it for you this time.
    Edited by: Matt on Nov 6, 2008 12:08 PM

    Hi Sunny,
    My suggestion is go txcode BAPI.
    After this in the left side of the window complete information on BAPIs will be available search out in Human resource you may get the BAPI, in the mean while some one may help you.
    Cheers!!
    VEnk@

  • Valid to date for BOM Header and Item

    Hello everyone,
    I have been searching for "valid-to" date for BOM header and Items since several days but no luck ..
    I know we can see it using transactions cs11/cs03 etc. But i wish to know the table where they are stored. As I need to extract them to BW.
    Any help will be highly appreciated.
    Thanks in advance!
    Regards,
    Anuj

    Hi Anuj
    In table STPO,the field AEDAT gets updated only when a change number is used,otherwise the valid to date will be shown nil here.
    And also ref the link
    Problem finding Valid To Date or Change number to on BOM
    pavan

  • Table to know the last loaded date for a ODS  and InfoObject?

    Table to know the last loaded date  and time for a ODS  and InfoObject?

    Hi Muruganand,
        The only way is through code ... there is no direct and simple method ... what you need to do is find hte highest Timestamp value for DP_NR = 000001. Then get the request field (RNR) ... this is the last request. Since you have to do it for 300 cubes ... I suggest you do some coding .. I can guide you through if you need assistance.
    Best regards,
    Kazmi

  • Calculate data of last 30 days on basis of sys date

    SELECT DT, ITEMCODE, ITEMNAME, QTY
    FROM   TABLE1In above given query, how i could calculate the QTY details of last 30 days, APR, MAY, and JUNE
    As the current month is JULY, in AUG, the Qty details are required for last 30 days (from sysdate), MAY, JUNE, JUL
    Please suggest.
    Yogesh
    Edited by: user12957777 on Jul 28, 2010 3:16 AM

    Hi,
    Use CASE expressions to filter data in particular columns:
    SELECT     SUM ( CASE
                WHEN dt >= ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
                             , -3
                AND  dt <  ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
                             , -2
                THEN qty
               END
             )          AS third_month
    ,     SUM ( CASE
                WHEN dt >= ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
                             , -2
                AND  dt <  ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
                             , -1
                THEN qty
               END
             )          AS second_month
    ,     SUM ( CASE
                WHEN dt >= ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
                             , -1
                AND  dt <               TRUNC (SYSDATE, 'MONTH')
                THEN qty
               END
             )          AS last_month
    ,     SUM ( CASE
                WHEN dt >= TRUNC (SYSDATE) - 30
                AND  dt <  TRUNC (SYSDATE)
                THEN qty
               END
             )          AS last_30_days
    FROM     table1
    ;You can do this with GROUP BY, also, if you want separate rows for each itemname (for example).
    I had to guess at some things, such as what you mean by the last 30 days.
    If you'd like to post some sample data 9CREATE TABLE and INSERT statements) and the results you want from that data, then I could test this.

  • How to  find the Open sale orders till date for  given plant and material ?

    Hi experts,
                     I have a requirement to calculate the open sale orders for a given plant and material. I have tried in VA05 wherein i can get only for the material and sales area combination. From the document nos obtained from VA05 i can then find the plant. But my question is how do i get the output of VA05 into my progra. (can i use submit for a module pool report ).
    Also if ther is some other standard table or Function module to find the open sale orders till a given date ,it will be even more helpful....in which case i can drop the VA05 route.
    Kindly help
    Thanks in advance
    Ashwin

    Hi Ashwin,
        You can use SAP Tables VBAK and VBUP to get to know if the document is complete or not.
       VBUK-GBSTK is the field that will give you the status of the Sales Order .
      VBUK is used at header level , whereas VBUP is used for Item level.
      So in your case what I would do is :
      Get the Sales Orders that satisy the plant and material criteria from VBAP table , take this Sales Document numbers and go to VBUK or VBUP table to get the Sales Order Status. 
       If I need to find the open quantity as well I will link to VBFA table based on the document number.
      Reward if helpful.
    Thanks,
    Imran

  • 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

Maybe you are looking for

  • Grayish grid on zoomin in. How to get rid of it?

    Hello everybody. So, here you see this monster above who kills my view when zooming picture in more than 500%... I looked out for some checkbox in preferences to turn it out, but can not see it. How can I get this of?? Thanks for christmas's help;)

  • I am using apex 4.2 and in sample application i cant find the administratio

    i am using apex 4.2 and in sample application i cant find the administration module through which i can add users. I dont think that facility is available in 4.2 kindly confirm pls Any information shall be appreciated Thanks Edited by: susf on Nov 26

  • Most common JRE version today?

    I'm trying to develop an applet and I have trouble deciding on which version of the JRE to base it on. I know of some machines still running JRE 1.4.2, perhaps due to enterprise IT policy. I was told the most common JRE I can assume to be the most wi

  • 11g BPM Global Activity with instance access equivalent ??

    Hi, I want to be able to update an instance variable from a workspace view much as I could with a 10g Global Activity with Instance access. As always I guess there are a number of solutions (even if they dont match the scenario exactly) but which is

  • Keynote to play as a screensaver/personal digital signage?

    I want to be able to have a Keynote slideshow that I've created for our family play on the iMac in our Family Room much like a screensaver. I want to keep this updated with pictures, upcoming events, reminders, etc. Almost like a family or personal d