Date Function to get Previous week

Is there a date function to get
Let us say today is 23rd of Jun 2009
I want a date function to get previous Thursday 18 Jun 2009
and another function which get 7 days before which is Friday 12 Jun 2009.
FYI: For the current week, I was able to use:
select next_day(case to_char(sysdate,'Day') when 'Thursday' then trunc(sysdate-1) else trunc(sysdate) end, 'Thursday')
from dual;
select next_day(trunc(sysdate-7), 'Friday') from dual;
I want something similar to that.
Thanks

No, not separate functions, but you can tweak next_day to get what you want:
select trunc(sysdate) today,
       next_day(trunc(sysdate)-1, 'THURSDAY')-7 last_thursday,
       next_day(trunc(sysdate)-1, 'FRIDAY')-14 prev_2nd_friday
from   dual;
TODAY     LAST_THUR PREV_2ND_
23-JUN-09 18-JUN-09 12-JUN-09

Similar Messages

  • Could not get Previous Week Day starting today

    I need help  to get PREVIOUS WEEK day starting today.
    Eg:
    Today is 15 / 09 / 2011
    I need Date 08 / 09 / 2011
    Hence both 15th and 08 are Thursday. One is today's thursday and other is previous week thursday.
    Regards

    Warranty on iPhone is not international, but valid only in country of
    original sale. Since you purchased the iPhone in Australia, your warranty
    is valid only in Australia. You must either personally return the iPhone
    to Australia for evaluation and possible replacement or sent it to someone
    in Australia to take into Apple for the evaluation. Apple will not accept
    international shipments for repair nor will Apple ship out of the country
    after replacement.
    Sorry to be the bearer of this news, but it is the way iPhone warranty and
    replacement has always worked.

  • DATE function to get name of day for a Date given?

    hi guys,
    can anyone tell me what is the DATE function to get the name of day for a date given
    (12/dec/2004)---returns SUNDAY

    Hi peter
    Your Query will return an error.
    SQL> select to_char(to_date('12/dec/2004', 'mm/mon/yyyy'), 'DAY')from dual;
    select to_char(to_date('12/dec/2004', 'mm/mon/yyyy'), 'DAY')from dual
    ERROR at line 1:
    ORA-01816: month may only be specified once.
    month is specified twice.
    select to_char(to_date('12/dec/2004', 'dd/mon/yyyy'), 'DAY')from dual;
    Regards
    Sasidhar.P

  • Getting previous weeks data based on parameters entered

    I am using CRXI. I have a RT that gives me the current week data but I need to be able to report on previous week data based on the paraments so if I enter dates between sunday and saturday of one week it will report on those data plus the same days of the previous week. I looked at the lastfullweek function, but not sure how to implement it in my scenerio. any ideas?
    Ralph

    That worked, thankyou. My next question along the same lines, is I am also having a third column that will indicate the percent change. for example
    Current             Previous              % Change
    97                    108
    I am trying to computer the % change between curent and previous basically it would look at previous as being the control and computer positive or negative based on what current is. I can do the math formulas, but I'm not sure what to comute to find the % change.
    Ralph

  • Function Module - Calculate Previous Week

    Hi Guys,
    I am looking to create a variable on Fiscal Period/Year, that automatically populates the variable with the previous week (current week minus 1), when the user runs the query.
    I have heard there is a Function Module available - can anyone help?
    Thanks
    Scott
    Message was edited by:
            Scott Sweeney

    Hi,
    use the following code:
    DATA: l_curr_week LIKE SCAL-WEEK.
    DATA: l_prev_week LIKE SCAL-WEEK.
    DATA: l_day TYPE DATS.
    CALL FUNCTION 'DATE_GET_WEEK'
      EXPORTING
        date               = SY-DATUM
    IMPORTING
       WEEK               = l_curr_week.
    CALL FUNCTION 'WEEK_GET_FIRST_DAY'
      EXPORTING
        week               = l_curr_week
    IMPORTING
       DATE               = l_day.
    SUBTRACT 1 FROM l_day.
    CALL FUNCTION 'DATE_GET_WEEK'
      EXPORTING
        date               = l_day
    IMPORTING
       WEEK               = l_prev_week.
    hope this helps...
    Olivier.

  • What is function module get previous date by enteing no of days

    FM should take : 7 days
    and should return : 4.12.2007
    as output.
    Thanx,
    Naveen

    Hi,
    Apart from function module, you can write as follows.
    data : date1 type datum,
           date2 type datum.
    date1 = sy-datum.
    date2 = date1 - 7 .
    write date2.

  • XLR Get Other Data Function

    Hi all,
    Im wondering if I can use cell valeu data in the Where clause of the GetOtherData function.
    EG Get Invoice Key where Payment No = whatever is in cell D9.
    I keep getting syntax errors.
    I'm trying to report accross 2 modules - AR and Banking.
    I need to display Invoice data as well as related payment data.
    In report composer after making my AR selections, I try to drag and drop data from the Banking module to show payment data related to the Invoices.
    The data is not retrieved.
    I was wondering if this might be possible using the GetOtherData function in Advanced Report Builder.
    Can I show data related to whats in a certain cell in my report?
    Thanks for any suggestions.
    John O'Brien

    Hello,
    In composer, you cannot use two modules together to get the information in each module.
    Get other Data function can get the value in a specific field in tables. Please check online help file, there is detailed example about it.
    the syntax in using Get Other Data is exactly same in SQL.
    Thanks,
    Maggie An
    SAP Business One Forum Team

  • Condition field in XL Reporter Get Other Data function

    I want to use the XL Reporter "Get Other Data" function to get data from a file not in the current Business Partner dimension  BPA.  Using the SalesPerson code SlpCode, I want to get the SalesPerson Name, SlpName. What is the value for the condition field to restrict the retrieval to just the one record that matches the SlpCode in the BPA dimension?  I've tried ocrd.SlpCode=oslp.SlpCode.  I've tried SlpCode=oslp.SlpCode. But I either get all the names in the Salesperson file or I get some type of syntax error.

    Jim,
    When you say I should be able to pass a parameter, do you mean while using the XLR "Get other data" function?  I thought that's what I was doing when I filled out the Get other data screen with the userid, password, then I specified the OSLP table, requesting SlpName in the Fields section, and then in Condition, I specified OCRD.SlpCode = OSLP.SlpCode.   When the report ran, I got a "#ixGetData error: The multi-part identifier "OCRD.SlpCode" could not be bound".   I tried substituting the BPA dimension qualifier, ie: BPA.SlpCode, but got the same error.
    If I removed the initial qualifier in the Condition field, ie: SlpCode = OCRD.SlpCode, when I ran the report I got ALL Salespersons names, not just the one that matched the SlpCode field on the current Business Partner line.

  • 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

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

  • Function Module - Calculate 5 weeks lookup based on -7 increments from the Key Date

    Hi Guys,
    I am looking to create a variable on Fiscal Period/Year, that automatically populates the variable with the previous 5 weeks based on -7 increments from the key date , when the user runs the query .
    For Example: If key date is 03/11/2014 need to get previous 5 weeks 03/04/2014, 02/25/2014, 02/18/2014, 02/11/2014, 02/04/2014. mm/dd/yyyy.
    Is there any Function Module available/ please provide the logic code - can anyone help?
    Thanks,
    Suresh Narayan

    Hi suresh,
    Please once try with this approach,
    Create a variable with variable represents :  multiple input value, Processing type : customer exit ; variable is ready for input.
    and write the below code :
    if i_step = 1.
    data : fdate type d ,
            wa1 like line of e_t_range,
           n1 type i.
    n1 = 1.
    if n1 <= 5.
    wa1-opt = 'EQ'.
    wa1-sign = 'I'.
    wa1-low = fdate.
    append wa1 to e_t_range.
    fdate = fdate - 7.
    endif.
    endif.
    Hope you got it,

  • Previous week data required

    Hi all,
    In my query user want to compare this week data verses previous week data. How can I get data which are there in previous week.
    I donu2019t have loading date in my info provider.
    Please suggest.

    Hi,
    See the Customer Exit Code, you need have only 0CALDAY incube you can get the data.
    ZCDAY = Use input Variable on 0CALDAY
    ZFDFW & ZLDFW  are Customer Exit variables on 0CALDAY.
    To Get the First day of First Week in given Date
    WHEN 'ZFDFW'.
          DATA: zdf1 TYPE sy-datum,
                zldate TYPE sy-datum,
                zday(2) TYPE n,
                zmnth(2) TYPE n,
                zyear(4) TYPE n.
          zday(2) = '01'.
          LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZCDAY'.
            CLEAR l_s_range.
            zmnth = loc_var_range-low+4(2).
            zyear = loc_var_range-low+0(4).
            CONCATENATE zyear zmnth zday INTO zdf1.
            l_s_range-low = zdf1.
            l_s_range-sign = 'I'.
            l_s_range-opt = 'EQ'.
            APPEND l_s_range TO e_t_range.
            CLEAR l_s_range.
          ENDLOOP.
    To Get the Last day of First Week in given Date
    WHEN 'ZLDFW'.
          zday(2) = '07'.
          LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZCDAY'.
            CLEAR l_s_range.
            zmnth = loc_var_range-low+4(2).
            zyear = loc_var_range-low+0(4).
            CONCATENATE zyear zmnth zday INTO zdf1.
            l_s_range-low = zdf1.
            l_s_range-sign = 'I'.
            l_s_range-opt = 'EQ'.
            APPEND l_s_range TO e_t_range.
            CLEAR l_s_range.
          ENDLOOP.
    Note: In this way you need to calcukate, here I'm dividing the month into weeks based on 7 days this is my company policy, so you need to check with your Functional team how they divides a week in a month.
    Thanks
    Reddy

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

  • Previous week Dates

    Hi all
    Please help in writing a query to get the previous week data.
    If the input date is sysdate then it should return values for previous week Monday to Sunday.
    Whatever the input it should get the value for previous week from Monday to Sunday.
    Thanks
    Jo

    IW is the formatter for the "Iso-Week"
    ISO = international standard organization
    See also: http://en.wikipedia.org/wiki/ISO_week
    Main thing is that it will always start with monday. The weeknumber might be different then for ww format. This doesn't matter in your case. But you migh want to do some experiments with to_char(sysdate,'IW'), to_char(sysdate,'WW').
    Trunc(<datevale>,'IW') will cut the date back to the first day of this iso-week.
    select to_char(sysdate-365,'IW') IW , to_char(sysdate-365,'WW') WW from dual;
    IW     WW
    37     36Edited by: Sven W. on Sep 9, 2010 2:29 PM

  • To get time-booking entered thru CATW,CAT2 for the previous week

    Hi Experts,
    I need to analyze the absences booked by an emolyee. I have obtained the time-booking for the present week from the user-exit where I am writing the code. But I have to check the booking of the previous friday (previous week) to check if the same absence is taken on Monday (current week). Thus I have to check the booking made by the employee on friday previous week. How can I get the time booking data for the previous week?
    Do we have any Fm to get that?
    Thanks
    Akash

    BAPI_ABSENCE_GETDETAIL         Read absence
    BAPI_ABSENCE_GETDETAILEDLIST   Read instances with data
    BAPI_ABSENCE_GETLIST           Read instances
    But you need for CATSDb ie for CATS
    use standard trans code cats_da ie rcats_report_activities
    also we have bapis
    BAPI_CATIMESHEETMGR_CHANGE     CATS: Change data records
    BAPI_CATIMESHEETMGR_DELETE     CATS: Delete Data Records
    BAPI_CATIMESHEETMGR_INSERT     CATS: Insert data records

Maybe you are looking for

  • Core file creation in weblogic 10.3 with 1.6.0_24 ( Urgent )

    Hi ALL , Recently we have migrated the java version from 1.6.0_16 to 1.6.0_24 in production environment . We are using weblogic 10.3 . Once from the migration the managed servers is going to unknown state at sometime which is configured as cluster co

  • Merge 3 Unlinked Reports into a single Report

    I have 3 Crystal Reports with  different structures and groupings, I want to view it in single report .Right now I'm using Embedded Crystal Report hence I'm unable to merge it through the code .I require a solution to this. Thanks a lot in advance.

  • Selecting specific instance of XML element for binding

    I am trying to create a form that will display ratesheets used to show mortgage rates.  We have an XML schema defined that has multiple rates for multiple products.  The rates change continuously. I want to create a static PDF by combining a form and

  • Bussiness System

    Hi Experts,                1,   In Integration Directory , When trying to Assign Business System to Scenario, it shows following details,                    Communication Component: | Q01CLNT118 is already locked in change list Standard change list b

  • DW8 and Recordset collation 

    Hi everyone My problem is not new but i didn't solve it completely. When i working with PHP MySQL server model in Dreamweaver 8 i have the collation problem with results on my pages. It can be well when the adding this code after mysql_select_db() li