Calculate week number (DIN EN 28601)

HI,
how can I calculate the proper week number for Germany? So the first
week in year is the week with at least four days (Thursday at least
01.01). So I have some problems with leap years and so on. One of the
problems is to know that the last days of a year can be in the first
week of next year (such as 31.12.2002).
Who can help me?
Thanks and best regards
Marco

JB wrote:
Yes, this is a great VI ! Thanks Rolf !
  However, we have modified it sligthly to handle some strange cases that may occur.
  One
of those strange cases was the first day of this year.
The weeknumber was 52 and the year 2006. Although both are
correct, you will get an erroneous date if you combine them. In fact,
if you label a product with this date, the customer will think that it
was produced the last week of 2006.
  In this case, you must either change the weeknumber to 1 or the year to 2005.
  There are some other modifications like the input type of the date that we changed to a time stamp control.
What
you did are practical modifications but they are not to the definition
of the ISO norm. If you modify week to 1 the supposed date is one week
later than what ISO really means and only if you change year to 2005
are you sort of correct.
I didn't use the time stamp string because this function was written in
a LabVIEW version that hadn't a timestamp type and can be loaded in
such LabVIEW versions AFAIR.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

Similar Messages

  • How to calculate week number from system date

    Hi experts,
    how to calculate week number from system date  ?
    thanks.
    SK

    hi,
    The above FM can be used for BADI or customer exit, if it is design level then you can use formula as well, under formula date functions you can use DATE_TO_WEEK.
    regards,
    Arvind.

  • XSLT Mapping: how to calculate Week number of the year from given date

    Hi,
    I  have input as date, i need to know the Week number from that date in XSLT Coding.
    for Eg: if date is 29-12-2009 it should give 53rd week of the year.
    All answers will be appreciated.
    Regards,
    Mayank

    Hi add this statement to your XSLT Mappping
    <xsl:stylesheet version="1.0" xmlns:java="http://xml.apache.org/xslt/java" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="java">
    and use <xsl:template name="GetDateInLocal" xmlns:cal="xalan://java.util.GregorianCalendar"> in XSLT Mapping , write your logic.
    cheers,
    Raj

  • Week number calculations not working ...

    Why doesn the week number calculation (ISO 8601) using datepart ('ww',#date#,crMonday,crFirstFourDays) not work?
    As an example do the following formula:
    DatePart('ww',CDate(2005,1,1),crMonday,crFirstFourDays)
    The result is 9363, quite an impressive week number
    This is an issue in versions 2008, XI R2, XI, 10 and possibly previous versions too

    Hi Raghavendra
    No I want to be able to calculate week number according to the week numbering definition from ISO 8601 - have a look at [http://en.wikipedia.org/wiki/ISO_week_date|http://en.wikipedia.org/wiki/ISO_week_date]
    If you want to use datepart ('ww, ... to solve this,
    you have to specify crMonday as third argument and crFirstFourDays as argument number 4 to tell datepart that weeks starts on mondays and week #1 is the one with the first 4 days of the year.
    Doing this makes my example date  used with datepart returns the week number 9363!!
    The DatePart('ww',CDate(2005,1,1),crMonday,crFirstFourDays) is supposed to return 53!!
    Weeknumbers are supposed to be between 1 and 52 or 53 depending of the year.
    Be aware weeks number 1, 52 and 53 very often contains days from 2 consequtive years, when defined according to ISO 8691.
    Your suggestion does not take into account the fact Weeks start on mondays and january 1st is not always the first day of week 1.
    It returns week number 1
    In fact it seems every day in the start of a year with weeknumber starting in the previous year gets the weeknumber calculated wrong.
    Regards,
    Poul
    Do you want to calculate the weeknumber of a particular date? If so please try datepart('ww',CDate(2005,1,1)).
    If not could you please explain me what you are trying to calculate and what output you are expecting?
    Regards,
    Raghavendra

  • ABAP Get Week Number for a Given Date.

    Hi All,
    I want to calculate week number for given date.
    SAP has provided function modules like DATE_GET_WEEK.. Etc are giving week number. taking default start day as Monday. But for my requirement is calculate week number based on start day as Sunday.
    Please let me know if we have any custom logic ??
    Thanks & Regards
    Vasu Yadav

    Hi Vasu,
    SAP standard functionality takes MONDAY as first day.
    But if you want then you can change it to SUNDAY by implementing BADI CALENDAR_DEFINITION. Create a new implementation for method IF_CALENDAR_DEFINITION~GET_FIRST_DAY_OF_WEEK and assign value as SUNDAY.
    Hope it solves your problem.
    Thanks
    Saurabh Kabra

  • 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

  • Urgent ---calculate version  from the current week number

    hi,
         i have an requrenment to modify the charasteric routines
      i have xxx table with parameter i have to read this paramater n  if this parameter contains value 'D' then calculate version(eg:- A00,A01 ...) from the current week number.
    pls advice me which FM i have to call or provide me with some sample codeing.
    points wil be rewarded
    ravi

    There is a FM "WEEKNR_GET".
    This will give you the week no. You need to read the param value from the table that you mentioned and call this FM and updat the version.
    You will need a ABAP person to do this.
    Ravi Thothadri

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

  • Week Number of the current week...URGENT

    hi gurus,
    I want to calculate the week number of the current week as per Fiscal year.
    What variable or the Customer Exit code needs to be written for it?
    regards

    Hi Venu,
       Use the code below. I assume that the client is US based where the Fiscal Year starts 1st October every year.  Just in case the fiscal year starts in some other month then adjust the code (if SY-DATUM+4(2) >= 10.) below. Hope this helps.
    DATA: PFY(8)   TYPE C.
    DATA: CFY(4)   TYPE C.
    DATA: LFY      TYPE I.
    DATA: FYD      TYPE I.
    DATA: TWD      TYPE I.
    DATA: RES      TYPE I.
    if SY-DATUM+4(2) >= 10.
      concatenate SY-DATUM+0(6)
                  '01'
             into PFY.
    else.
      LFY = SY-DATUM+0(4).
      LFY = LFY - 1.
      CFY = LFY.
      concatenate CFY
                  SY-DATUM+4(2)
                  '01'
             into PFY. 
    endif.
    FYD = P_FY.
    TWD = SY-DATUM.
    RES = ( TWD - FYD ) / 7.
    Write: Res.

  • How do I look for a date that corresponds to a particular Week Number in a table?

    Hello,
    I have a table (Table A) that looks like this (I am only including the first 5 months to keep image size down):
    The numbers in the table are dates, with custom formatting to just show the day.
    I have another table with all of the Week Numbers for a given year in the first column and a second column in which I would like a formula to count the numbers of dates in Table A that correspond to the Week Number in the first column (i.e. the number of dates that falls within that week).
    The following statement works for testing single cells:
    =COUNTIF(WEEKNUM(Table A :: $Session 1 $January,2),A1)
    But it would seem that I can only use this with single cells and not the table as a whole.
    Could someone help with a solution to this?
    Thanks,
    Nick

    Thanks Jerry.  If I have understood you correctly I would need to calculate the week numbers of the dates in Table A in Table A itself, like this:
    Then I would use the COUNTIF function to test the array of week numbers in Table A.  If this is correct, I am not sure how to construct an array that includes just the cells with week numbers. I presume I could do this either manually or based on the value in the first column of Table A (i.e. just testing the five columns to the right of each "Week No" row), but I'm not sure.
    Nick

  • Problem in week number

    Hi,
    We are using BO XI R2 Desktop intelligence to create a report.
    I tried  to create a variable week.It is giving wrong week number.
    It is calculating the week from Monday to sunday.
    But i need to calculate the week from Sunday to Saturday.
    I need to change that.Is there anyway to change this?
    The week number for the date 3rd Feb,2008 is 5.But in my report it is showing as 4.
    Where i have to change the settings?
    Please help on this.
    Thanks,
    Indu.

    Indu,
    There is no setting in WebI that you can use to overcome this "problem".
    The solution that many developers employ is in adding a "business calendar" table to their data warehouse.  In your case you are interested in the date and its mapping to a week so you would thus create two columns in your business calendar table, one with every date of the year and the other column with its corresponding week indicator.  You will have to populate this business calendar table with all dates that are particular to your operation (past and future) to encompass a full reporting capability.  Most developers sometimes also embellish this table with things like business Fiscal Year indicators, business day, weekend, and holiday indicators, etc, etc.
    Thanks,
    John

  • Calculate Weeks in a period

    Hi All,
    How do I calculate the number of weeks in a given period.
    say for example
    startDate = 24th Nov 2002
    enddate = 31st dec 2002.
    How can I find the weeks within this period.
    I tried calculating the time difference but that didn't help.
    Any Ideas?

    codingMonkey wrote:
    gcameo wrote:
    Weeks as in calendar weeks (Sunday - Saturday = 1 week) or just seven consecutive days (Wednesday - Tuesday = 1 week)?7 Consecutive daysThe easiest way, without using a third party library, in my opinion is the following. Get the difference between the two dates in milliseconds, divide that by 1000 to get seconds, divide by that 60 to get minutes, and so forth until you get the difference in weeks. I'll leave it up to you to write the code. Good luck!
    As always, there might be a class/method somewhere in the standard API which provides an easier way of doing this. If anyone knows of such a class or method, please enlighten me and the OP.I have used the Joda-time library extensively before for this kind of work but in my current company, "ReInvent the Wheel Limited", I can't use it...hence my struggles.
    Anyway, thanks

  • How to display week number in a report

    Hi,
    I need to show the week number in a report and related sales data for that week. For example, starting from 01-JUL-2009 the week1 should show total of sales from 01-JUL-08-JUL.
    Help please....
    Thanks
    A/A

    If you are trying to extract the week number of the calender year...you can use..
    sql> select to_char(sysdate,'WW') from dual;
    TO
    05and then group the sales figures by week...
    sql> create table t(
      2     target_date date,
      3     sales       number);
    Table created.
    sql> begin
      2     for i in 1..30 loop
      3        insert into t values (sysdate-i,100*i);
      4     end loop;
      5   commit;
      6  end;
      7  /
    PL/SQL procedure successfully completed.
    sql> select week, sum(sales) from (
      2     select sales, to_char(target_date,'WW') week from t)
      3   group by week;
    WE SUM(SALES)
    05       2100
    02      16800
    01       8800
    04       7000
    03      11900However, if your week calculation starts with a particular date like a calender year starting with 01-june-2010, then you would need to calculate the (relative) week number using something like...
      1  select target_date,
      2         trunc(((target_date - to_date('01-june-2010','DD-MON-YYYY'))/7)) week_number
      3*   from t
    sql> /In the above code, 01-june-2010 is the date from which my calender year starts.
    Please note that since this is relative, you might get negative numbers for weeks.

  • Computing date of 1st Monday of a week given the week number?

    I've got the week numbers (1-52) and would like to calculate the 1st monday given that week number.  I'm hoping for a format like Jan 12
    Is this possible to do?
    ajw

    this page appears to have a few formulas that you may be able to use: http://mathforum.org/dr.math/faq/faq.calendar.html
    wikipedia also includes a few as well: http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week
    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com
    Strategic Data Systems - for all your SharePoint needs

  • How to format a date to display the ISO week number in BI Publisher ?

    Hi there,
    I need to format a date to display the ISO week number in BI Publisher.
    I've tried the following <?format-date:NEED_BY_DATE;'WW'?>, but it returns a week number (1-53) where week 1 starts on the first day of the year and continues to the seventh day of the year, which is not what I want.
    I want the ISO week number (1-52 or 1-53), the one implemented by the 'IW' format mask of the Oracle PL/SQL TO_CHAR() function for example.
    I've tried using 'IW' format mask, but it is not recognised by BI Publisher.
    Also, as I'm working on an RTF template, I've tried 'IW' as MS Word date format, but it is not recognised by MS Word :-((
    Any help would be much appreciated,
    Regards - Hugues

    Hi,
    Thank you for the post.
    The thing is I don't have access to the query, unless I modify a standard E-Businees Suite view (one of those used to generate the PO document in Purchasing).
    Regards - Hugues

Maybe you are looking for

  • Desktop software 7.1

    Is it necessary to download desktop software 7.1 on a PC in order to transfers and/or sync files from a PC onto a BB Playbook? Is it necessary to use HDMI cable to transfer/sync movies, videos and songs from a PC to a BB Playbook, or USB cable and WI

  • Output by email

    HI, How to send order confirmation output through email pl suggest where all  configuration must be done for this

  • Microsoft Outlook hangs under Lion

    Ever since installing Lion, my Microsoft Outlook hangs all the time. I'll be in the middle of typing an email when the spinning beachball pops up for about 30 seconds or more, then I can start again.  This can happen every few minutes or hours in bet

  • Can't uninstall CS3... no error, just nothing happens

    I'm trying to uninstall CS3 in preparation to install CS5... But nothing happens. I click on CS3 in Programs and Features and then click uninstall. I get the small blue wheel by the cursor for a few seconds then nothing happens. no error. no message

  • Essbase studio unicode character issue

    Hi all, We are facing issues in Essbase Studio when records with unicode character is encountered. E.g. We have a field like City BUCUREȘTI with a unicode character. So when the record with this filed comes, it concatenates the part of the filed (Cit