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.

Similar Messages

  • OBIEE 11.1.1.6.12 - sum of payments starting from the beginning of prompt month

    Hi all,
    how do I calculate sum of payments starting from the beginning of prompt month in OBIEE 11.1.1.6.12 ?

    used firefox no issues but in ie not seeing any issues

  • Populate week number: week starts from saturday

    Hi All,
    We populated the calendar table where we have populated the week number (1-53) by taking sunday as the week start date.
    But we need to populate the weeknumber(1-53), with week start day as saturday.Please
    Here is the alredy populated data.
    Day WeekNumber Mon date
    Sunday     1     January     1/1/2012
    Monday 1 January 1/2/2012
    saturday 1 January 1/7/2012
    Sunday 2 January 1/8/2012
    we have to populate the weeknumber with saturay as the weekstart date
    Thanks All.

    Hmmm , after re-reading the OP's question I realise I have provided a comprehensive and well-researched answer to a different question. Must be getting over-excited, it being so close to Christmas. Anyway, I'm going to leave this answer up for the time being, until I can find a better home for it.
    The day number is a function of your NLS_TERRITORY setting, a parameter derived from NLS_LANG . For instance when the locale is 'AMERICAN' the first day of the week is SUNDAY but when the locale 'ENGLISH' it's MONDAY. It is possible to mix'n'match language and territory. [url http://docs.oracle.com/cd/B28359_01/server.111/b28298/ch3globenv.htm#i1007222]Find out more.
    So, if you set the NLS_TERRITORY to somewhere in the Islamic world, say Kuwait, you will find that Saturday is day 1 of the week. You can do this at the session level:
    sql> alter session set nls_territory = 'KUWAIT';
    Session altered.
    SQL> select to_char(sysdate+1, 'DAY') as day_name
       2            , to_char(sysdate+1, 'D') as day_no
       3    from dual;
    DAY_NAME  D
    SATURDAY  1Cheers, APC
    Edited by: APC on Dec 21, 2012 11:07 AM

  • Calendar to get week number of current month

    Hi All,
    Description: Currently I am working on an application which require to calculate some data for current month from a database where I have the data of all the previous and current month of that year, I can take week number as criteria.
    Help Required: I can find week of month or year using Calendar methods but how to find the first week on the current month only.
    Lets suppose the current month is April so when I use, int weekofmonth = cal.get(cal.WEEK_OF_MONTH);
    it will return me the number of present week however I want to get what would be the week number at the start of the month (April).
    Hope I am able to describe my query properly.
    Thanks in advance.
    Amit

    / ====================================================
    Method: Get the desired Date format for the date
    Developed By: Sandip Waghole [29-Jan-2010]
    ==================================================== /
    public String getWeekNo(String strDate)
    // input Date Format : M/dd/yyyy
    int weekNo=0,i=0;
    String strWeekNo=null;
    int noOfDaysInTheYear=365;
    int WEEK_STARTS_ON = 1; // Define the day on which week starts Sunday/Monday 1:Sunday 2:Monday
    int firstDayNoInFirstWeekOfPresentYear=0; // Inititalize teh day on which week is starting in present year
    int firstDayOfPresentYear=0; // Inititlize the 1st day of the present year whether Sunday/Monday/.....
    int[] monthDaysArray = {31,28,31,30,31,30,31,31,30,31,30,31}; // Define array of the days as per months
    int todaysDayNoInPresentYear=0;
    int daysLateByFirstWeekStartedAfterYearStarted=0;
    int intTemp=0;
    //strDate="08/24/2000"; // For test purpose
    StringTokenizer strDateTok = new StringTokenizer(strDate, "/ ");
    int month = Integer.parseInt(strDateTok.nextToken());
    int day= Integer.parseInt(strDateTok.nextToken());
    int year = Integer.parseInt(strDateTok.nextToken());
    GregorianCalendar cal = new GregorianCalendar();
    // Check if present year is leap year
    boolean boolIsLeapYear = cal.isLeapYear(year);
    // If it is boolean year then add 1 to total days in the year & add one more day to february
    if(boolIsLeapYear)
    noOfDaysInTheYear=noOfDaysInTheYear+1;
    monthDaysArray[1]=monthDaysArray[1]1;
    // Find the 1st day of this year
    Calendar calObj = new GregorianCalendar(year, Calendar.JANUARY, 1);
    firstDayOfPresentYear = calObj.get(Calendar.DAY_OF_WEEK);
    int intRemoveNoOfDaysFromWeek=0;
    // # Find the day no of prsent day
    for(i=0;i<month;i+) // get no of days till present year
    intTemp = intTemp monthDaysArray;
    todaysDayNoInPresentYear = intTemp - (monthDaysArray[month-1]-day);
    if(firstDayOfPresentYear==6 || firstDayOfPresentYear==7) // If first Day is Friday or Saturday then it is week
    // Identify the the day no on which 1st week of present year is starting
    firstDayNoInFirstWeekOfPresentYear = 7 - firstDayOfPresentYear WEEK_STARTS_ON 1;
    // Find delay in the 1st week start after r=the year start
    daysLateByFirstWeekStartedAfterYearStarted = firstDayNoInFirstWeekOfPresentYear - 1;
    // Now week is starting from Sunday
    weekNo = (Integer)((todaysDayNoInPresentYear-daysLateByFirstWeekStartedAfterYearStarted)/7);
    // Find the day no of today
    intTemp = (todaysDayNoInPresentYear-daysLateByFirstWeekStartedAfterYearStarted) % 7;
    if(intTemp > 0)
    weekNo=weekNo+1;
    else
    weekNo=weekNo;
    else
    // 1st week is starting on 1st Of January
    firstDayNoInFirstWeekOfPresentYear=firstDayOfPresentYear;
    // Remove no. of days from the 1st week as week is starting from odd Sunday/Monday/Tuesday/Wednesday/Thursday
    intRemoveNoOfDaysFromWeek = 7-firstDayOfPresentYear 1; // 1 added as include start day also
    // So one week will be added in no. of weeks
    weekNo = (Integer)((todaysDayNoInPresentYear-intRemoveNoOfDaysFromWeek)/7);
    // Find the day no of today
    intTemp = (todaysDayNoInPresentYear-intRemoveNoOfDaysFromWeek) % 7;
    weekNo = weekNo +1; // As 1st weeks days are reduced from the todays day no in the year
    if(intTemp > 0)
    weekNo=weekNo+1;
    else
    weekNo=weekNo;
    // Remove the no. of days from the week 1
    strWeekNo=Integer.toString(weekNo);
    return strWeekNo;
    // Any issues please mail on [email protected] or [email protected]

  • Get Week Number of Current Month

    How can I get the week number of the current month (1-5)?
    This is what I have tried and I'm not getting the expected
    results.

    quote:
    Originally posted by:
    DJ5MD
    Does your go 1-5 since it's only 30 days? Is that the
    difference?
    I think he was referring to your comment "How can I get the
    week number of the current month (1-5)?". Some months can have 6
    weeks so you should take that into account.
    Both the function from cflib.org and his code should return 6
    for 2007-09-30.

  • ORDER way week start from MONDAY [Mon...Sun]

    Display the last name, hire date, and day of week on which the employee hire.
    Order the result by the day of week starting with Monday.
    (eg. Monday,Tuesday……Saturday,Sunday)
    I have tried this using following statement…..But is this right way!? Any other command availabe for same.
    SELECT last_name, hire_date, TO_CHAR(hire_date,'Day')
    FROM employees
    ORDER BY TO_CHAR(hire_date -1,'d') ;
    [FROM  ORACLE University Introduction to Oracle9i: SQL Vol 1, Chapter 3, Q.10, PAGE NO 3-64]

    i think i will also works
    decode(to_char(hiredate,'d'),1,null,to_char(hiredate,'d'))This is very nls-dependant:
    begin
      for cTerr in (select value from v$nls_valid_values where parameter = 'TERRITORY') loop
        begin
          dbms_session.set_nls('nls_territory', ''''||cTerr.value||'''');
          if to_char(to_date(7,'j'), 'd') not in (2) then -- Monday
            dbms_output.put_line(cTerr.value || '=' || to_char(to_date(7,'j'), 'd'));
          end if;
        exception
          when others then
            dbms_output.put_line(cTerr.value || '=?');
        end;
      end loop;
    end;
    /Look for example at BANGLADESH

  • How to get the date starting from 1 to the current date from the system dat

    Dear all,
    Please tell me how to get the date starting from 1 based on the system date
    and it should come with respect of time also.
    example.
    suppose today is 6 Dec, 2006
    so ABAP report should find the 1 dec. 2006.
    Please help me as soon as possible.
    Regards,

    concatenate sy-datum0(2) '01' sy-datum4(4) into v_firstdate.
    or yo ucan use the fm:
    HR_JP_MONTH_BEGIN_END_DATE
    usage:
        call function 'HR_JP_MONTH_BEGIN_END_DATE'
             exporting
                  iv_date             = sy-datum
             importing
                  ev_month_begin_date = gv_begda
                  ev_month_end_date   = gv_endda.
    Regards,
    Ravi
    Message was edited by:
            Ravi Kanth Talagana

  • Flash CC "stream" mp3 clip starts from beginning, regardless of current frame

    I have an mp3 set to "stream", it's 25.7 seconds long, 41.1k, 16-bit, mono. "Stream" works fine when I scrub through the timeline by mouse, but during playback, the clip always start from the beginning, so it is out of sync unless I start from the first frame. How can I fix this? It makes the program much less usable for lip-sync.

    I do see a bug logged internally for this. However since this is inconsistent repro, it will be great if you can PM me the test file that shows this problem.
    -Sujai

  • SSRS Matrix report. Variance expression by Month. Need to compare month from prior year to current month of current year VS2010

    Please help.  I have a matrix report.  In the report I have row group  PO Type.  One the Column groups I have a parent group by Fiscal Year, and then a child group by Month.  When I run the report, I get two years of data back broken
    out by month.  Please see below.
    Now here is where I am getting stuck.  I need to take the variance between the current month of the current year, from the same month of the prior year.  So I need to show the difference between Oct , 2014 from Oct, 2013. November, 2014 from November
    2013... etc. etc.
    In the example below, how do I create a column or row showing the variance for Contracts for October 2014.  I need to take the contracts for October 2014 which is 3 and subtract that from October 2013 which is 8.  Any suggestions? How do I do that
    for each month?  Then I need to do it for the quarter... then the year?  But I'll be happy if I can just get the month working first.
    Any help will be appreciated. 
    here is what my rdl file looks like.
    Here is what my report looks like when I render it.

    Hi Adrian_s2012,
    According to your description, you want to compare values for the month of current year with the month of prior year and get the variance. Right?
    In Reporting Services, we don't have any function to get this "Year to Year" Growth. In this scenario, if you data source is a cube, we suggest you use Analysis Services to achieve your requirement. If this data source is just from database, it will be hardly
    to calculate the variance because we need to compare the values within every two different column group and matrix generate adjacent columns one by one. Even we make it by using custom, every time executing the long code when generating result
    in a cell will reduce a lot of performance, we really don't suggest to do that in SSRS. Here is a thread with much easier requirement, please take a reference of that:
    http://social.msdn.microsoft.com/Forums/office/en-US/842e2dcb-d949-4297-9d91-eac989692cb5/difference-between-the-grouped-column?forum=sqlreportingservices
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Get all the back schedule start date except last and current month

    Hi All;
    Below gives me last month  schedule start
    scheduledstart >= DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0)
    AND scheduledstart < DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)
    Below gives me current month  schedule start
    scheduledstart >= DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0)
    AND scheduledstart < DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())+1, 0)
    I need to find all the schedule start excluding current month and last month
    Any help on this much appreciated
    Thanks
    Pradnya07

    Hi,
    You could use NOT BETWEEN with the start date of last month and the end date of the current month:
    AND schedulestart NOT BETWEEN DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0)
    AND DATEADD(MONTH, DATEDIFF(MONTH,
    0, GETDATE())+1,
    0)
    Hope this helps,

  • How to get week starting with sunday date

    Hi
    I have a date column "start_date", i need to create a report for all the weeks starting from sunday , for eg:
    i need to get week dates as :
    mm/dd/yy - 01/23/11 , 01/16/11 , 01/09/11 and so on...
    Please help
    Thanks...

    Hi,
    To find the last Sunday before or equal to start_date:
    SELECT     TRUNC ( start_date + 1
               , 'IW'
               ) - 1          AS week_start_date
    ...You can use an expression like this in a GROUP BY clause, also.
    This does not depend on you NLS settings. ISO weeks always start on Monday. Your week starts 1 day earlier, so that's why the expression above has the +1 and -1.
    (Depending on you NLS settings,
    SELECT     TRUNC ( start_date
               , 'D'
               )          AS week_start_date
    ...might do the same thing, but I still rocommend using 'IW'; a few extra keystrokes isn;t much to pay for a guarantee that it will always work.)
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.

  • BI Query - Date Selction- week starts Tuesday

    Gurus,
    We have EP, BI ABAP and JAVA systems on Nw7. All end user executes queries trough EP.
    There are few BI queries where users need to enter date for execution of query.
    For execution of such query user is entering date using F4 (search).
    Select values for Calendar day (COMICAL 0003)--> Opens calendar and it is fine. Issue is week of this calendar starts with Tuesday.
    This behavior varies with workstations. Over few work station calendar week starts on Monday which is required.
    However over few workstations week starts on Tuesday.
    Any guess which property of work station needs to be tuned to have week starting from Monday.
    ps: I have checked Data and time setting of work stations and they are same.
    Thanks !!
    ARD

    Any luck over this vage issue....

  • How to get Current Quarter and Fiscal Quarter for a Date - Fiscal Year starts from 1st April

    Hi, 
    I need to calculate current quarter and fiscal quarter in my Sql query.
    I have a column for DateTime Datatype. 
    I need to find out Current Quarter Name like Q12012, Q22012, Q32012, Q42012 and Fiscal Quarter Name as well.
    Now Fiacal Year starts from 1st April, and Current Quarter starts from 1st Jan.
    For Current Quarter of 2012
    Jan-Mar = Q12012
    Apr-Jun = Q22012
    Jul-Sep = Q32012
    Oct-Dec = Q42012
    For Fiscal Quarter of 2012 ( starts from 1st Apr, 2011 )
    Apr2011-Jun2011 = Q12012
    Jul2011-Sep2011 = Q22012
    Oct2011-Dec2011 = Q32012
    Jan2011-Mar2012 = Q42012
    means if its 1st April, 2012,
    its a new Fiacal Year 2013 so Fiacal Quarter Name should be Q12013
    and its Current Quarter Name should be Q22012
    Can you help me to calculate this in a select query for given dates?
    Thanks in advance, 
    Nirav

    This should do it..
    Select
    FORMAT(datepart(quarter,getdate()),'Q#')+FORMAT(getdate(),'yyyy')

  • Calendar starts from Sunday ...

    Hi folks,
    Currently the calendar in BI Publisher starts from Sunday. Is it possible and eventually how to change it as our week starts from Monday.
    Thanks in advance,
    Rossy

    Rossy
    Not in the current release - we are looking to release better control over calendars in an upcoming release.
    Regards
    Tim

  • Archive start from sequence=2...

    Hi All,
    After completion Database (10g) installation on solaris machine , check the sequence number from v$log view as shown below : it display sequence 2 is current and archive is also start from sequence 2.(check this archive files manually from log_archive_dest_1's location.)
    but when we are looking for any recovery scenarios then will it be asking for archive sequence 1?
    select * from v$log;
    GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
    1 1 2 52428800 2 NO CURRENT
    2 1 0 52428800 2 YES UNUSED
    3 1 1 52428800 2 YES INACTIVE
    Can any one suggest me why it's start from sequence 2 as current instead of sequence1?
    Thanks...

    Furthermore, read my earlier reply about the backup : "As you haven't taken any Database Backup yet, the archivelogs that are currently being generated will not be required in a Recovery scenario -- you can't begin Restore+Recovery until you have a Backup to Restore."
    Even if log sequence#1 did get archived, it is meaningless. Any archives created before any database backup are unusable in a Recovery situation. A Recovery can apply archivelogs only from the point when a backup was created. You wouldn't, COULDN'T, have taken a Backup before Log Sequence#1 , so there won't be a need for an archive log of that file.
    The situation when Log Sequence#1 is archived is IF a database, being already in ARCHIVELOG mode, is opened with RESETLOGS , for example, after an Incomplete Recovery. Then, the next archive would be Log Sequence#1 of the Incarnation created by the ResetLogs .

Maybe you are looking for

  • Mac Pro 2.0 outperforming Mac Pro 2.66, WHY?

    Ok Guys, I am stumped here and hopefully someone can shed some light. I have 2 Mac Pros: System 1 - 2 x 2.66 with 9GB of memory and System 2 - a recently acquired 2 x 2.0 with 5 GB of memory. System 1 has banks filled as follows: Riser A Bank 1: 2gb

  • Save and Close goes to error page after modifying List in Infopath

    Hi, I have a list in Sharepoint 2013 which I have modified using Infopath 2013. After modification, If i open the list in Sharepoint site, i am not able to Save or Close the list. It gives "The webpage cannot be found" error. Regards, Shreyas R S

  • JTextPane and Horizontal Scrollbars

    Hi there, I had written an app that included an Event Log, and all was good in my world. Then one of the app users commented they would like errors to stand out within the log! I said "No Problem" but it turns out to be a major bloody headache!!!!! I

  • JDeveloper 10.1.3.4.0 and getter/setter

    Is there a generate getter/setter functionality in this version of JDeveloper? I can't seem to find it.

  • How to set a form field focus

    Is there a simple way to set a form field focus... so basically on load the field focus is set to a specific field?  I know how to write it in javascript but was wondering if there is a simple way to basically select the field and click a button or t