Date range by week based on input parameters

Afternoon folks -- I need to produce a report which will be displayed based on weeks.
There are two input parameters: P_FROM_DATE and P_TO_DATE
I need to find the date ranges in weeks starting on THURSDAY and ending on a WEDNESDAY. For example, if my P_FROM_DATE is 01-AUG-2012 and P_TO_DATE is 11-SEP-2012, I need to show the following weeks in this fashion:
02-AUG-2012 - 08-AUG-2012
09-AUG-2012 - 15-AUG-2012
16-AUG-2012 - 22-AUG-2012
23-AUG-2012 - 29-AUG-2012
30-AUG-2012 - 05-SEP-2012
06-SEP-2012 - 12-SEP-2012So, the idea is to start the first THURSDAY following the P_FROM_DATE and end on the WEDNESDAY preceding the P_END_DATE..
Thanks!

Hi,
here's one way:
WITH     params          AS
     SELECT  DATE '2012-08-01'     AS p_from_date
     ,     DATE '2012-09-19'     AS p_to_date
     FROM     dual
,     end_points     AS
     SELECT     TRUNC ( p_from_date + 4
                , 'IW'
                ) + 3          AS first_thursday
     ,     TRUNC ( p_to_date + 4
                , 'IW'
                ) - 5          AS last_wednesday
     FROM    params
SELECT     first_thursday + (7 * (LEVEL - 1))     AS week_start_date
,     first_thursday + (7 * LEVEL) - 1     AS week_end_date
FROM     end_points
CONNECT BY     LEVEL     <= ( last_wednesday
                  + 1
                  - first_thursday
                  ) / 7
;TRUNC (dt) is the beginning of the ISO week that contains the DATE dt.
The "magic number" 4 is used because the ISO week begins on Monday, 4 days later than your week begins, so
TRUNC ( dt + 4
      , 'IW'
      )is the Monday in the same Thursday-Wednesday week as dt.

Similar Messages

  • Is it possible to use a case statement when joining different tables based on input parameters?

    Hi,
    I have a scenario where my stored procedure takes 5 parameters and the users can pass NULL or some value to these parameters and based on the parameters, I need to pull data from various tables.
    Is it possible to use a case statement in the join, similar the one in the below example. I'm getting error when I use the below type of statement.
    select a.*
    from a
    case
    when parameter1=1 then
    inner join a on a.id = b.id
    when parameter1=2 then
    inner join a on a.id = c.id
    end;
    Please let me know, if this type of statement works, and if it works will it create any performance issues?. If the above doesn't work, could you please give me some alternate solutions?
    Thanks.

    Here's a technique for joining A to B or C depending on the input parameters. In theory, you are joining to both tables but the execution plan includes filters to skip whichever join is not appropriate. The drawback is that you have to do outer joins, not inner ones.
    CREATE TABLE A AS SELECT LEVEL ak FROM dual CONNECT BY LEVEL <= 100;
    CREATE TABLE b AS SELECT ak, bk
    FROM A, (SELECT LEVEL bk FROM dual CONNECT BY LEVEL <= 10);
    CREATE TABLE c(ak, ck) AS SELECT ak, bk*10 FROM b;
    variable p1 NUMBER;
    variable p2 NUMBER;
    exec :p1 := 1;
    exec :p2 := 20;
    SELECT /*+ gather_plan_statistics */ A.ak, nvl(b.bk, c.ck) otherk FROM A
    LEFT JOIN b ON A.ak = b.ak AND :p1 IS NOT NULL AND b.bk = :p1
    LEFT JOIN c ON A.ak = c.ak AND :p1 is null and :p2 IS NOT NULL and c.ck = :p2
    WHERE A.ak <= 9;
    SELECT * FROM TABLE(dbms_xplan.display_cursor(NULL,NULL,'IOSTATS LAST'));
    | Id  | Operation             | Name            | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
    |   0 | SELECT STATEMENT      |                 |      1 |        |      9 |00:00:00.01 |       7 |
    |*  1 |  HASH JOIN OUTER      |                 |      1 |      9 |      9 |00:00:00.01 |       7 |
    |*  2 |   HASH JOIN OUTER     |                 |      1 |      9 |      9 |00:00:00.01 |       7 |
    |*  3 |    TABLE ACCESS FULL  | A               |      1 |      9 |      9 |00:00:00.01 |       3 |
    |   4 |    VIEW               | VW_DCL_5532A50F |      1 |      9 |      9 |00:00:00.01 |       4 |
    |*  5 |     FILTER            |                 |      1 |        |      9 |00:00:00.01 |       4 |
    |*  6 |      TABLE ACCESS FULL| B               |      1 |      9 |      9 |00:00:00.01 |       4 |
    |   7 |   VIEW                | VW_DCL_5532A50F |      1 |      9 |      0 |00:00:00.01 |       0 |
    |*  8 |    FILTER             |                 |      1 |        |      0 |00:00:00.01 |       0 |
    |*  9 |     TABLE ACCESS FULL | C               |      0 |      9 |      0 |00:00:00.01 |       0 |
    Predicate Information (identified by operation id):
       1 - access("A"."AK"="ITEM_0")
       2 - access("A"."AK"="ITEM_1")
       3 - filter("A"."AK"<=9)
      5 - filter(:P1 IS NOT NULL)
       6 - filter(("B"."AK"<=9 AND "B"."BK"=:P1))
       8 - filter((:P2 IS NOT NULL AND :P1 IS NULL))
       9 - filter(("C"."AK"<=9 AND "C"."CK"=:P2))
    You can see that table C was not really accessed: the buffer count is 0.
    exec :p1 := NULL;
    SELECT /*+ gather_plan_statistics */ A.ak, nvl(b.bk, c.ck) otherk FROM A
    LEFT JOIN b ON A.ak = b.ak AND :p1 IS NOT NULL AND b.bk = :p1
    LEFT JOIN c ON A.ak = c.ak AND :p1 is null and :p2 IS NOT NULL and c.ck = :p2
    WHERE A.ak <= 9;
    SELECT * FROM TABLE(dbms_xplan.display_cursor(NULL,NULL,'IOSTATS LAST'));
    Now table B is not accessed.
    | Id  | Operation             | Name            | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
    |   0 | SELECT STATEMENT      |                 |      1 |        |      9 |00:00:00.02 |       7 |      2 |
    |*  1 |  HASH JOIN OUTER      |                 |      1 |      9 |      9 |00:00:00.02 |       7 |      2 |
    |*  2 |   HASH JOIN OUTER     |                 |      1 |      9 |      9 |00:00:00.01 |       3 |      0 |
    |*  3 |    TABLE ACCESS FULL  | A               |      1 |      9 |      9 |00:00:00.01 |       3 |      0 |
    |   4 |    VIEW               | VW_DCL_5532A50F |      1 |      9 |      0 |00:00:00.01 |       0 |      0 |
    |*  5 |     FILTER            |                 |      1 |        |      0 |00:00:00.01 |       0 |      0 |
    |*  6 |      TABLE ACCESS FULL| B               |      0 |      9 |      0 |00:00:00.01 |       0 |      0 |
    |   7 |   VIEW                | VW_DCL_5532A50F |      1 |      9 |      9 |00:00:00.01 |       4 |      2 |
    |*  8 |    FILTER             |                 |      1 |        |      9 |00:00:00.01 |       4 |      2 |
    |*  9 |     TABLE ACCESS FULL | C               |      1 |      9 |      9 |00:00:00.01 |       4 |      2 |

  • How to calculate start date of the week based on week number ?

    i need to get week number of the current date and based on that i need to calculate start date falling in the same week for last year.
    Eg. today is 31st week of year and 31st july date. so what will be the date on the 31st week of last year. i need the start date of that week.
    we can calculate the week number by select to_char(sysdate,'ww') from dual.
    DO we have a single line query for that or will it require writing a pl/sql block ?

    you can try following query
    it can be as inline but for more clean look and create it as select with include select
    with t as
    (select sysdate as dt from dual)
    select to_char(prev_year_dt - to_char(prev_year_dt, 'D') + 1, 'DD.MM.YYYY') as start_of_week from (select
    -- get day from prev year with the same week number
        case
               when to_number(to_char(add_months(dt, -12), 'WW')) > to_number(to_char(dt, 'WW')) then
                dt - (to_number(to_char(add_months(dt, -12), 'WW')) - to_number(to_char(dt, 'WW'))) * 7
               when to_number(to_char(add_months(dt, -12), 'WW')) < to_number(to_char(dt, 'WW')) then
                dt + (to_number(to_char(dt, 'WW')) - to_number(to_char(add_months(dt, -12), 'WW'))) * 7
               else
                add_months(dt, -12)
           end as prev_year_dt
      from t) t1good luck
    Sergii
    'Monday' is not first day of week in 100% ;)
    Edited by: Galbarad on Jul 30, 2012 11:00 PM

  • Autofill dates for a week based on date selected...

    If I have a table that has Monday-Friday on it and I want to select the date on Monday and have it fill in the dates for the rest of the week, how would I do that. Or is there a way so that when it is opened on Monday, it inputs the date into the cell for Monday, then on Tuesday when it is opened, it inputs the date into the cell for Tuesday without changing the date in Monday's box? Either way is fine with me. Thanks!

    Here's a sample. https://workspaces.acrobat.com/?d=bWS4uDJgJKsWM8USbHsuKg
    In the Week Ending field you select the date - in this case it is checking to make sure that a Saturday is selected. From there it fills in the dates for the fields.

  • Break Date Range by Week / Month

    I have an ArrayCollection which is made up of Objects in the following form:
    AC = { site='abc.com' date="2009-10-01" visits="2000" ...},
         { site='abc.com' date="2009-10-02" visits="2000" },
         { site='abc.com' date="2009-10-03" visits="2000" },
         { site='abc.com' date="2009-10-04" visits="2000" },
         { site='abc.com' date="2009-10-04" visits="2000" },
         { site='abc.com' date="2009-10-05" visits="2000" },
         { site='abc.com' date="2009-10-06" visits="2000" },
         { site='abc.com' date="2009-10-07" visits="2000" },
         { site='abc.com' date="2009-10-08" visits="2000" },
         { site='xyz.com' date="2009-10-01" visits="2000" },
         { site='xyz.com' date="2009-10-02" visits="2000" },
         { site='xyz.com' date="2009-10-03" visits="2000" },
         { site='xyz.com' date="2009-10-04" visits="2000" },
    I'd like to break up this ArrayCollection into Weeks and Months. As in, group them into an Advanced Datagrid by Group Week.
    I imagine I should be adding a key to each object that specifies Week 1, Week 2, etc; by getting the getDay() to being 1 (for Mondays), and the result would be:
    AC = { site='abc.com' date="2009-10-01" visits="2000" week="Week1"},
         { site='abc.com' date="2009-10-02" visits="2000" week="Week1"},
         { site='abc.com' date="2009-10-03" visits="2000" week="Week1"},
         { site='abc.com' date="2009-10-04" visits="2000" week="Week1"},
         { site='abc.com' date="2009-10-04" visits="2000" week="Week1"},
         { site='abc.com' date="2009-10-05" visits="2000" week="Week1"},
         { site='abc.com' date="2009-10-06" visits="2000" week="Week1"},
         { site='abc.com' date="2009-10-07" visits="2000" week="Week1"},
         { site='abc.com' date="2009-10-08" visits="2000" week="Week2"},
         { site='abc.com' date="2009-10-09" visits="2000" week="Week2"},
         { site='abc.com' date="2009-10-10" visits="2000" week="Week2"},
         { site='xyz.com' date="2009-10-01" visits="2000" week="Week1"},
         { site='xyz.com' date="2009-10-02" visits="2000" week="Week1"},
         { site='xyz.com' date="2009-10-03" visits="2000" week="Week1"},
         { site='xyz.com' date="2009-10-04" visits="2000" week="Week1" },
    Anybody got any other ideas?

    Hi,
    here's one way:
    WITH     params          AS
         SELECT  DATE '2012-08-01'     AS p_from_date
         ,     DATE '2012-09-19'     AS p_to_date
         FROM     dual
    ,     end_points     AS
         SELECT     TRUNC ( p_from_date + 4
                    , 'IW'
                    ) + 3          AS first_thursday
         ,     TRUNC ( p_to_date + 4
                    , 'IW'
                    ) - 5          AS last_wednesday
         FROM    params
    SELECT     first_thursday + (7 * (LEVEL - 1))     AS week_start_date
    ,     first_thursday + (7 * LEVEL) - 1     AS week_end_date
    FROM     end_points
    CONNECT BY     LEVEL     <= ( last_wednesday
                      + 1
                      - first_thursday
                      ) / 7
    ;TRUNC (dt) is the beginning of the ISO week that contains the DATE dt.
    The "magic number" 4 is used because the ISO week begins on Monday, 4 days later than your week begins, so
    TRUNC ( dt + 4
          , 'IW'
          )is the Monday in the same Thursday-Wednesday week as dt.

  • Query to get date range in Week

    Hello all,
    I wanted the get the results in terms of week like, if sysdate is 26/7/2007 Then
    I have to get previous 7 weeks including the week where sysdate exists.
    Results should come in this manner
    23rd to 27th 1 week
    16 - 20th July 2007 as 2nd week like this till 7 weeks
    I have a query but it is not giving in the above manner
    So please anybody can make a query as mentioned above.
    Query:
    SELECT TO_DATE(TO_CHAR(SYSDATE,'DD-MON-YYYY')) + ( ROWNUM - 6)+(ROWNUM+2)D,TO_DATE(TO_CHAR(SYSDATE,'DD-MON-YYYY')) + ( ROWNUM - 6)+(ROWNUM+2) R FROM DUAL CONNECT BY LEVEL < 6

    What do you want?
    -- A week
    select sysdate, sysdate+7 from dual;
    --A week from monday to sunday
    select nexT_DAY(SYSDATE, 'MONDAY'), NEXT_day(sysdate-7, 'SUNDAY') FROM DUAL
    BE CAREFUL MONDAY AND SUNDAY IF YOUR DDBB IS IN ENGLISH
    select
    nexT_DAY(SYSDATE, 'MONDAY'), NEXT_day(sysdate-7, 'SUNDAY'), TO_char(sysdate,'d'),
    (sysdate -TO_char(sysdate,'d')) as firstone,
    (sysdate + 7-TO_char(sysdate,'d') )as lastone
    FROM DUAL
    Message was edited by:
    cth

  • Creating a Tabular Form based on Input Parameters passed from another page?

    Hello,
    APEX version 3.2
    DB version 9.2
    Internet Explorer 6
    I created a tabular form, but do not want to return all the records from the table.
    Is it possible to create a parameter page for the user to enter a string of values that will be submitted to create a tabular form, only displaying those records from the table?
    Thanks.

    Why not use an instr with your data in a bind variable in your where clause for the select?? Page 1 sets an item called P2_Parameter with your value string slightly modified ('12345','345632','645534534','3434344')
    Select a,b,c,d,e from some_table where INSTR(TO_CHAR(Lookup_column,'099999999'),:P2_Parameter)
    Maybe that will work? Its off the top of my head, but should get you what you want.. (But to agree with one of the other posters, it is a BAD Design..) I would try like an interactive report to allow them to enter in acct #'s or whatever these are and let them access the rows that way..
    Thank you,
    Tony Miller
    Webster, TX

  • Date Range Issue

    Hi Experts,
    I have created a linked server to connect to mysql DB . The query is executing fine currently filter is based on the on going month.
    The query actually fetches the records from 2 tables User and time sheet to find how many hours the users have  .
    Now we check the Hours for a period of 10th of the current month and 10th of the upcoming month .
    So for now date range will be  between 2014/10/05 and 2014/10/06.  This logic i have implemented in the query .
    Based on the query a report is generated which is sent out every Wednesday  .Now suppose its 5th of June 2014 . 
    The query will fail because the date range is derived based upon
    where cast(t.created_on as Date) > Concat(year(now()),"-",month(now()),"-","10")
     AND cast(t.created_on as Date) <=Concat(year(now()),"-",month(now())+1,"-","10")
    Please provide with a date filter like the report runs anytime the data is not affected. Like if the report is run in the
    first week of a new month  date range should be previous month Date 10 and current month  Date 10 and if the report is run after 10th of the current month then the date range should be between 10th of current month and 10 of upcoming month . Kindly
    help
    Select * From
    OPENQUERY
    (Mysql,
    'Select
     Sum(t.hours),
     Concat(u.firstname," ",
     u.lastname) as Name
     From mysql.time_entries t
     Inner Join
     users u
     on u.id = t.user_id    
     where cast(t.created_on as Date) >
     Concat(year(now()),"-",month(now()),"-","10")
     AND
     cast(t.created_on as Date) <=Concat(year(now()),"-",month(now())+1,"-","10")
     Group By u.firstname,u.lastname
     Union all
     Select Sum(0) as hours,
     Concat(firstname," ",
     lastname) as Name
     from users
     where id not in(
     Select
     t.user_id
     From mysql.time_entries t
     Inner Join
     users u
     on u.id = t.user_id    
     where cast(t.created_on as Date) >
     Concat(year(now()),"-",month(now()),"-","10")
     AND
     cast(t.created_on as Date) <=Concat(year(now()),"-",month(now())+1,"-","10"))
     And firstname not in( "xyz")
      GRoup by firstName,lastname'
      go

    I recommend use CLOSED-OPEN dates rather than OPEN-CLOSED dates...
    Hopefully this helps with your logic:
    DECLARE @ReportDate TABLE
    [ReportDate] DATE,
    [mDay] AS DAY([ReportDate]),
    [Beg] AS DATEADD(month, CASE WHEN DAY([ReportDate]) < 10 THEN -1 ELSE 0 END, [ReportDate]),
    [End] AS DATEADD(month, CASE WHEN DAY([ReportDate]) < 10 THEN 0 ELSE 1 END, [ReportDate]),
    [ReportBeg] AS DATEADD(month, CASE WHEN DAY([ReportDate]) < 10 THEN -1 ELSE 0 END, DATEADD(day, 10 - DAY([ReportDate]), [ReportDate])),
    [ReportEnd] AS DATEADD(month, CASE WHEN DAY([ReportDate]) < 10 THEN 0 ELSE 1 END, DATEADD(day, 10 - DAY([ReportDate]) + 1, [ReportDate]))
    INSERT INTO @ReportDate(ReportDate)
    VALUES
    ('7-May-2014'),
    ('10-May-2014'),
    ('15-May-2014');
    SELECT
    CASE WHEN SYSDATETIME() >= [ReportBeg] AND SYSDATETIME() < [ReportEnd] THEN 1 ELSE 0 END
    FROM @ReportDate;

  • SAP HANA Input parameters in SAP BO Analysis

    Hi, dear experts.
    Please help me with one problem in SAP BO Analysis. Problem is: in sap hana studio i made calculation view that has some input parameters (Param. type - Direct, Sematic Type - Date, Data type - Date). Then i made filter with this parameters in one of projection of my calculation view. When i push data preview in Hana Studio all input parameters are ready to input and they also have "Value help dialog". All is great! SAP HANA Studio version is 1.0.7000 (Build id: 386119). HANA DB version is 1.00.70.00.386119.
    On workstation i installed SAP BO Analysis edition for Microsoft Office 32-bit and driver for SAP HANA 70 Client Win32, made ODBC connection to HANA server. From SAP BO Analysis I found my view and started it. I see my input parameters, and see "value help dialog", but i can't choose value: it's not available for input. Here is the problem: what i have to do to enter the parameters?
    I also try to use variable but value help dialog is empty. Please help me with this issue.
    Message was edited by: Tom Flanagan

    Hello Andrei,
    Tested on:
    HANA Rev 70
    Have tested for variables and the value help is coming.
    Regards,
    Krishna Tangudu

  • Missing date range in select

    Hello,
    Database Version 10gr2(10.2.0.5)
    This following data set is from my query, which the date range is weekly, where two week's date is missing (that's correct, because no data for those weeks). But I need to include that week date aslso with null or 0 values on. How to I select the running weeks from the following
    Current data set
    col1     week_date
    4     04/14/2012
    6     04/21/2012
    5     05/12/2012
    10     05/19/2012
    2     05/26/2012
    Expected result set
    col1     week_date
    4     04/14/2012
    6     04/21/2012
    *0     04/28/2012*
    *0     05/05/2012*
    5     05/12/2012
    10     05/19/2012
    2     05/26/2012Any help would be greatly appreciated.
    Thanks,

    Hi,
    You can use CONNECT BY to gerenate all the dates you need, then outer join your actualdata to that result set, like this:
    VARIABLE     start_date     VARCHAR2 (20)
    VARIABLE     end_date     VARCHAR2 (20)
    EXEC  :start_date := '04/14/2012';
    EXEC  :end_date   := '05/26/2012';
    WITH     all_dates     AS
         SELECT     TO_DATE (:start_date, 'MM/DD/YYYY')     + (7 * (LEVEL - 1))     AS week_date
         FROM     dual
         CONNECT BY     LEVEL <= 1 + ( ( TO_DATE (:end_date,   'MM/DD/YYYY')
                                     - TO_DATE (:start_date, 'MM/DD/YYYY')
                             / 7
    SELECT       COUNT (x.week_date)     AS col1
    ,       a.week_date
    FROM           all_dates  a
    LEFT OUTER JOIN  table_x    x  ON  a.week_date = x.week_date
    GROUP BY  a.week_date
    ORDER BY  a.week_date
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    See the forum FAQ {message:id=9360002}
    Edited by: Frank Kulash on May 21, 2012 5:05 PM

  • Get the date range

    Hi,
    There is a requirement that we need to get date range.This date range will be arrived at using the function module BKK_GET_PRIOR_WORKDAY. The factory calender id is GB. It should return the date range. Therefore, for weekends the date range will be Saturday, Sunday and Monday.  The date range will change based on holidays that exist in the holiday calendar.
    Now my question is how to calculate that there are two days between friday and monday.
    Please help.

    Hi Nishigandha,
    If i am correct you need the number of days between two dates
    ex:
    date1: 04/06/2009
    date2: 12/06/2009
    you need the number of days??
    then probably check this Fm out:
    SD_DATETIME_DIFFERENCE this is a function module which gives the difference in Days and Time for entered two dates
    P.S Additionally  Chk this out:
    /people/mustafabaris.gunes/blog/2009/03/16/calculating-number-of-working-days-in-query-level
    Hope its useful
    Thanks and Regards
    Srikanth.P
    Edited by: SRIKANTH P on Jun 4, 2009 2:33 PM

  • Calculate  date previous to given date range

    i have a date range in zproggram as user input but in my calculation i want one day prior date to date-high for eg
    user input is  1.08.2006 to 4.08.2006 but i need for further calculation date range as 1.08.2006  to 3.08.2006. can anybody help please . points will be given

    Hi Sarabjit,
    This is very simple..
    But the place where you add this code matters. You can not add this to INITIALIZATION event as the user will change the value after this..
    You cannot add this code to AT SELECTION-SCREEN events too.. as the user can execute them by pressing enter and then again can change the value.
    You can add this code in START-OF-SELECTION event.
    If your select option is s_date. A select option is an internal table. It has a sturcture as below:
    Sign --> 1 Character --> I (Include), E(Exclude)
    Option --> 2 Character --> EQ, BT, NE, LT, GT etc..
    low --> Low value  --> 8 char in this case
    High --> High Value --> 8 char in this case
    So, at the run time, you will have a record as:
    I BT 20070827 20070831
    Now, you want that the high value should be 1 day before..
    Code like this..
    IF NOT s_date[] IS INITIAL.
    LOOP AT s_date.
    IF NOT s_date-high IS INITIAL.
    s_date-high = s_date-high - 1.
    MODIFY s_date.
    ENDIF.
    ENDLOOP.
    ENDIF.
    Thanks and Best Regards,
    Vikas Bittera.
    **Points for useful answers **

  • Date Ranges: Page Items or 'Input Parameters'?

    Hi,
    What is the best way to implement an user input date range qualifier in worksheets?
    So far I've only been able to achieve this by using item classes on a date field. Very messy.
    Anyone else doing this?

    Thanks Gveeden.
    How do you setup your date parameters?
    Are they 'conditions'? If so, how do you let the Users specify values in User Edition?
    Hope you can help out.
    Thanks already,
    Peter Verhoeven.

  • If I give 27 th week of 2007, can I get date range ( any FM is there ?)

    In my selection screen I am giving 27 th week and year 2007,
    I need to know know the date range ( monday to sunday ) for that week .
    For eg. if I give <b>1st</b> week and year <b>2007</b>,
    It should display 01/01/2007 to 07/01/2007 ( like DD/MM/YYYY ).
    is there any function module available to know this ?

    Hi sam ,
    just execute the code by giving date and  see if this works for u ,,
    check with input as 01/01/2007 i hope this will do ..
    parameters : P_DATE LIKE SCAL-DATE.
    DATA : HDATE LIKE SY-DATUM,
           LDATE LIKE SY-DATUM.
    data: WEEKno  LIKE  SCAL-WEEK,
          refmonDAY  LIKE  SY-DATUM,
          REFSUNDAY  LIKE  SY-DATUM.
       CALL FUNCTION 'GET_WEEK_INFO_BASED_ON_DATE'
        EXPORTING
          DATE          = p_date
        IMPORTING
          WEEK          = weekno
          MONDAY        = refmonday
          SUNDAY        = refsunday.
          write:/ 'weeknumber', weekno, 
          write:/ 'monday' ,refmonday.
          write:/  'sunday', refsunday.
    see if this works for u ..
    can you can tell me ur input criteria as how u r passing the date if u r query is not completed ..
    regards,
    vijay

  • Finding the number of weeks or months in a Date range

    I have a couple of text boxes that a user inputs a start date and an end date. What I want to know is there a way to tell the number of months or the the number of days in this date range?
    For example:
    Start Date = 02/12/2004
    End Date = 03/12/2004
    The number of weeks = 4 //May not be accurate, just showing an example.
    The number of months = 2

    For month, I would define it as the dates that fall in the actual calendar month. If my start date input from the user is 1/21/04, then I want to define a time period of 1/21/04 through 1/31/04 to be included in the first month. I know that it is not an actual month, but I am trying to make graphs based on monthly performance.
    For weeks, I want the days to run Sunday through Saturday. If the first date starts on a Wednesday, then I want my first week to include days only Wednesday through Saturday.

Maybe you are looking for

  • RE: Legacy Integration with PI/Open

    Greg - We are currently working on wrappering the APIs for UniVerse (aka Pick on UNIX). We received some help from the guys at RTD in Denver. We tested out a C program that uses the Universe APIs and it works fine. We will be building the Forte piece

  • Silly Question regarding extended desktop

    I have just ordered a new 24" iMac however, the tech specs for the UK note: +Support for external display in video mirroring mode+ Where as the US tech specs note: +Support for extended desktop and video mirroring modes+ Which is correct? Does anyone

  • Is there an add on to attach a hyperlink to a word or phrase

    Say you are making a comment on a web page or blog and want to attach a hyperlink to a word or phrase - is there an add on for Firefox to do this

  • ADD device in Audible...Zen xtra don't w

    I have WIN98SE. I have a Zen Xtra 40gb. Latest firmware and drivers. Device manager sees Zen. I cannot get add device to work in Audible Manager (4.0). With the Zen connected, i do add device, and nothing happens. HELP!

  • PDF Output generates invalid Thai output

    PDF Output with English characters From Oracle Reports 6i is generated properly. We are facing problems while generating PDF OutPut with Thai characters . The Reports builder shows proper Thai Character, but when we generate to PDF file the output sh