IPCC 7 Determine the week number of a month

Hello,
I am working towards determine the week number of month and make appropriate routing changes only for that specific week. I have tried using the trunc(), getdate() and weekday(). But i fail to get the week number of a month, but I believe I have managed to the week number of a year.
The example I have considered is: On Tuesday and Thursdays in second week of every month the calls to be routed to a different skillgroup.
Please let me know if anyone has any suggestion for this.
Thanks,
FYI,
CM 4.1, CRS 3.5, ICM 7.1

Hi buddy,
Great stuff!! Your link gave me another hint of the possible solution, I was working on ICM but not sure why i did not consider CRS for this requirement , The CRS has a builtin function, I have used this builtin Methods which provided me what i expected.
The debug on the script resulted the week of the month for today which is "4".
Please let me know your view.
Thanks again!

Similar Messages

  • Best method to determine the week number of a month - SQL Server 2012

    Hi,
    I'm searching the most valid and tested method to determine the week number respect to a month.
    Fe, the 1st January falls in the 1st week of January, the 1st February fall in the 1st week of February, and so on.
    I've found many solutions but I'd like to know possibly the best one.
    Thanks

    Hi Uri,
    SELECT DATEPART(week, '20150104')
         - DATEPART(week, CONVERT(CHAR(6), '20150104', 112)+'01')
         + 1
    returns 2 and not 1. It's a Sunday.
    Waiting to be spoonfed, eh?
    The one-off in my query would be very simple to figure out - I forgot to add the +1. Is too much to expect from you that you could figure it out yourself?
    And likewise, in my post I said that you should use "week" for weeks starting on Sunday, and "iso_week" if your week starts on Monday. Uri neglected to observe this, but you had the information to correct it. If you had been interested
    in doing some work yourself, that is.
    Nevertheless, there is an issue that I overlooked:
    DECLARE @day date = '20160105'
    SELECT datepart(iso_week, @day) -
           datepart(iso_week, convert(char(6), @day, 112) + '01') + 1
    This returns -51. This is because with ISO week numbering, Jan 1st falls into week 53 of the previous year, if it's on a Friday or later. Week 1 is always the week of Jan 4th. When you week this does not happen, as week 1 is always the week with Jan
    1st. (Dec 31st is always in week 53 or 54.)
    To correct for this, we need this query:
    SELECT DATEPART(iso_week, @day) -
           CASE WHEN DATEPART(iso_week, CONVERT(CHAR(6), @day, 112) + '01') < 50
                THEN DATEPART(iso_week, CONVERT(CHAR(6), @day, 112) + '01')
                ELSE 1
           END + 1
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to determine the month from the week number?

    Hi all,
    in a routine i have the week number in a year and i need to find the month but i don't know the correct FM to use for this.
    Is there anyone that had to face a similar problem?
    I'm considering that to determine the month it will be used the first day of the week since there are weeks belonging to 2 different months...
    Thank you
    Stefano

    Hi
    If you have a Fiscal Year Variant determined for the week you can use function module PERIOD_DAY_DETERMINE by passing week,fiscal year and fiscal year variant for the week which will return fist and last date.So based on last data you can determine the month.
    Regards
    Srilaxmi

  • How do I set twice monthly events based on the week number

    Greetings all. I can't seem to navigate this help system, so hopefully I'm not reasking something that's already been asked. But I have a problem with iCal that I just can't figure out of find an answer to. I need to create a twice monthly event, but it's based on the week number, not every two weeks. For example, I need to be able to create an event for the 2nd and 4th Mondays of the month. Is that possible with iCal? Thanks for your help... and not laughing at me
    Steve

    No problem.
    Go to Monday select the day you want. Create new Event. Then select repeat and you will come up with how you want to repeate it. Select Monthly and then do the following:

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

  • Derive week number of that month

    Hi,
    I need to derive week number based on month.
    Ex:
    Sy-datum = 10.10.2010
    Month: 10.2010
    Calweek: 40.2010
    Week no: 2
    Sy-datum = 11.10.2010
    Month: 10.2010
    Calweek: 41.2010
    Week no: 3
    So for everymonth I need to store the week no in the cube
    Ex
    Date--Month--
    calweek............weekno
    10.10.2010.............10.2010.............40.2010...............2
    10.10.2010.............10.2010.............40.2010...............2
    10.10.2010.............10.2010.............40.2010...............2
    11.10.2010.............10.2010.............41.2010...............3
    11.10.2010.............10.2010.............41.2010...............3
    11.10.2010.............10.2010.............41.2010...............3
    So here i need to derive week number for a date in the month
    Can anyone please help what logic to be applied to get the week number?
    Thanks
    Annie
    Edited by: Annie on Oct 14, 2010 7:48 AM

    Hi Annie, I'm not very sure of any function modules, but you may try this logic:
    1. Date Format Stored in SAP: YYYYMMDD.
    2. Use a formula X+6(2) to get the DD part.
    3. Use Conversion Exit  'CONVERSION_EXIT_ALPHA_INPUT'
    4. Logic: [ DATUM's DD ] MOD 7 which gives the week # ordering for the particular month.
    5. Close the START Routine passing the temp value to RESULT.
    DATA:var_dd type sy-datum, var_temp(2) type i.
    var_dd = SOURCE_FIELDS-ZDATE+6(2).
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              INPUT  = var_dd
            IMPORTING
              OUTPUT = var_dd.
    if sy-subrc = 0.
    var_temp = var_dd MOD 7.
    end if.
    RESULT = var_temp.
    Pls. review & let me know your comments.
    Thanks.
    Edited by: Arun Bala G on Oct 14, 2010 12:22 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.

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

  • How to get the week number of year from a Date object?

    Hi!
    I would like to know the week number of the year from a specified Date.
    I dont know how to set the first day of week, and set the minimum days of a week.
    I want to use Monday for first day of week, and at least 4 days of month in a week.
    For example if its 1st, January is Friday, then the first week starts on 4th, Monday.
    Anyone can help?

    Sorry. I should think before I move.
         public static int getWeekOfYear(Date date) {
             Calendar calendar = Calendar.getInstance();
             calendar.setTime(date);
             calendar.setFirstDayOfWeek(Calendar.MONDAY);
             calendar.setMinimalDaysInFirstWeek(4);
             return calendar.get(Calendar.WEEK_OF_YEAR);
         }

  • How to return the week number starting from Sunday as the first day

    Hi Friends,
    My application needs to have a report for the weekly totals and must have the Sunday as the first day for the week. For example, January of 2005 should be in the report for having six weeks, Jan 1 is Saturday, this is week 1, Week 2 is from 2 to 8, and the last week , week 6 has 30 and 31. Days need not be displayed, only the week number as follows:
    Week Number Total Sales
    =========== =========
    Week 1 8,525
    Week 2 8,168
    Week 3
    Week 4
    Week 5
    Week 6
    The discoverer hierarchies function for week (eul_date_trunc(item_date, '"W"W')) seems to start the week from the first day of the month regardless of the day. Oracle function TO_CHAR(item_date, 'W') does the same thing, .As the result, the January of 2005 has only 5 weeks.
    Any help or advice for this issue will be greatly appreciated.
    Thank you very much,
    J.K

    Try this
    ---------------------------------------------actual formula---------------
    select ceil(
    ( to_number(to_char(to_date('1-'||to_char(sysdate,'MON-YYYY'),'DD-MON-YYYY'),'D')) -1
    + to_number(to_char(sysdate,'DD'))
    ) / 7
    week_number
    from dual
    e.g try different dates below by replacing 31-Jan-2005
    select ceil(
    ( to_number(to_char(to_date('1-'||to_char(to_date('31-JAN-2005'),'MON-YYYY'),'DD-MON-YYYY'),'D') ) -1
    + to_number(to_char(to_date('31-JAN-2005'),'DD'))
    ) / 7
    week_number
    from dual
    How does it work
    week number is calculated by dividing the current day number by number of days
    so in your case if the week starts at a different day , you just add the offset and divide by 7
    In the first part, i am finding the week day number for the 1st day of the current month and this is used as offset.
    Hope this helps
    -nj
    http://www.infocaptor.com

  • Return date for a given week number in a month

    Hi,
    Can someone urgently post a snippet code that will return the date if the week number and the weekday (like wednesday) for a given month in an year is passed.
    ex: If I say 2nd wednesday of August in 2004 , it must return the date for second wednesday. URGENT

    Don't flag your question as urgent, even if it is for you. Claiming urgency is very likely to be counter-productive: most forum regulars will simply ignore such messages as rude and selfish attempts to elicit immediate and special attention.
    Besides, unless the Symbionese Liberation Army is about to chase you over the edge of a cliff, your problem probably isn't as urgent as you think. :o)

  • How to get the week number for a given date?

    hi guys,
    what is coding to get the week number for a given date?
    For example, 1/1/05 is week 1. then 8/1/05 is week 2.

    The second parameter to pass to the method is supposed to be one of the month constants JANUARY - DECEMBER. It happens to be that their numerical values are 0-11, not 1-12, so your "12" refers to the "13th" month of the year.
    givenDate = new GregorianCalendar(2003, Calendar.DECEMBER, 31);
    If you want to construct dates and times from strings like you seem to be, look into SimpleDateFormat http://javaalmanac.com/egs/java.text/ParseTime.html
    (even still I got WEEK_OF_YEAR as 1 which is true but not really what I expected, excuse my previous reply but I wanted to check the facts before posting this)

  • Why is the week number in iCal not ISO8601?

    why is the week number in iCal not ISO8601?

    Error "The serial number is not valid for this product" | Creative Suite

  • Determine the fax number or EMAIL address for pur docs

    Hi,
    I am trying to send pur doc via fax or EMAIL.
    I have created specific  message types for that purpose.
    The fax is created and sent to the default fax number / EMAIL address.
    I want the message to be sent to the same vendor but to other fax number or EMAIL address.
    I do not want to create a spereate partner for that purpose. I want to add fax number or EMAIL number to the address detail of the vendor and I want to mark it as the fax number for the pur docs.
    In the UE/BADI I want to be able to determine the fax number / EMAIL address.
    Does any one know any BADI/UE enabeling me doing so?
    Best regards
    Shlomo Assouline

    Dear Ramesh,
    This is a known issue. What I am looking for is the place in which I can decide which one of the EMAIL/FAX that exists in the vendor master data to use.
    As you probably know A vendor can have more than one EMAIL/FAX but only one of them is signed as the default one. The EMAIL/FAX used as standard is the standard one.
    Best regards
    Shlomo Assouline

  • In C4: What determines the max number of slide one can successfully publish?

    Using C4.
    I am required by policy to use an original PowerPoint file. The total number of slide equals 72 (file size 38,201 KB when completed). The internal customer wants a "kicky" presentation based on her slides, so I must use some of the Captivate tools (e.g. zoom area, highlight box -- about the limit of my skills). And there must be spoken narration, not the text to speech feature. Total time for the 72 slides is 22.5 minutes when all is done. When published the narration is good, but the "kicky" part fails. Specifically some highlight boxes do not appear on many slides.
    I deleted the table-of-contents feature. The most unusual tools that I'm using are the certificate widget, and a page turning widget.
    I tried breaking the presentation into two parts. Part 1 was 58 slides and I experienced the same behavior. I've not tried part two yet.
    In the past, I practiced, on my computer, with the aggregator. Is this the best route? We have no experience hosting an aggregator project on our server. Are there any special concerns about doing so? (I'm not the person who does this. He is out of the office at this time). Would daisy-chaining be a better route? (if so, what is the best source for instruction to do this?)

    Again, I did not see the elephant in the room. I neglected to notice a default setting. Once corrected, everything works. My bad.
    But, I would still like to know what determines the maximum number of slides on can successfully publish without Aggregator or daisy-chaining.

Maybe you are looking for