LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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
0 Kudos
Message 1 of 6
(8,606 Views)


marco.wegner@kmw-gmbh.de wrote:
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


It's not just Germany or DIN but internationally standardized as ISO. Unfortunately LabVIEW is using the C runtime function strftime which uses ANSI norm (not as international of course!).

I've done a VI some time back and you can find it in following thread:

http://forums.ni.com/ni/board/message?board.id=170&message.id=99272&view=by_date_ascending&page=3

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
Message 2 of 6
(8,593 Views)

THANKS A LOT,

that´s it. And it works really fine. What I have tried looks much more difficult (and it doesn´t work...).

Best regards

 

Marco 

0 Kudos
Message 3 of 6
(8,573 Views)
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.
 
 
0 Kudos
Message 4 of 6
(8,556 Views)


@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
My Blog
0 Kudos
Message 5 of 6
(8,552 Views)

We usually label our motors with week number and year. Unfortunately, the ISO norm produces unacceptable results (when combining week number and year) for some exceptions, like 01.01.06.

Imagine the reaction of a customer when receiving motors labelled 52/06 in January ! Another problem would appear if the customer shipped motors back for repairing. This indication would lead to think that the motors were produced the last week of 2006.

So we had to adapt your VI to avoid those cases. As you probably noticed, we kept the ISO week number and changed the year when required.

Thank you once again for your work !

0 Kudos
Message 6 of 6
(8,538 Views)