Welcome! Log In Create A New Profile

Advanced

any function in windev to get work week & work dates?

Posted by PETER ZHOU 
PETER ZHOU
any function in windev to get work week & work dates?
December 27, 2008 10:41AM
Hi,

I need to generate report by week no. ( work week )..
eg.
Week no. 1 - from 01 to 02 JAN 2009
Week no. 2 - from 05 to 09 JAN 2009 and so on..

How to get the week number & the dates ?

Thanks in advance

Regards,

PETER ZHOU
Jimbo
Re: any function in windev to get work week & work dates?
December 27, 2008 11:30AM
Quote
PETER ZHOU
Hi,

I need to generate report by week no. ( work week )..
eg.
Week no. 1 - from 01 to 02 JAN 2009
Week no. 2 - from 05 to 09 JAN 2009 and so on..

How to get the week number & the dates ?

Thanks in advance

Regards,

PETER ZHOU

Hi Peter,

there's a function WeekNumber(..) for calculation of the ISO-week number in W-language which is only half of the cake.

Note: Calculation of week numbers can differ a lot !! There are some globally used algorithms with specific rules and there are even week-numbers with special algorithms for special organisations as for health or social security in several countries! We understand that PC Soft decided not to enter that minefield very similar to their decision not to provide a 'proper case' algorithm'. WeekNumber(..) will calculate the ISO-week number (starting on Monday) and will not assign a number to the week crossing year's end.

Mostly, the difference between algorithms is how to assign a number to the week which is common to the old and the new year.

The most common rule is: If three days or less of that week belong to the old year then the week will be the first week of the new year.

Of course, 'belong' is the problem here, because weeks start differently in different countries! The 'Christian' (and btw the ISO) week starts on Monday, because God rested on the seventh day (= Sunday). However, in the US, no less Christian, the week starts on Sunday and forces a different calculation.

My calculation of the ISO-week number looks as follows:
WochenTagNum = Day of Week (Monday = 1)
KalenderWoche = ISO-week number
Format of LastActiveDate = YYYYMMDD

WochenTagNum = IntegerToDay(DateToInteger(LastActiveDate))
KalenderWoche = WeekNumber(LastActiveDate)

IF Middle(LastActiveDate, 5, 4) = "1229" AND WochenTagNum = 1 THEN KalenderWoche = 1
IF Middle(LastActiveDate, 5, 4) = "1230" AND (WochenTagNum = 1 OR WochenTagNum = 2) THEN KalenderWoche = 1
IF Middle(LastActiveDate, 5, 4) = "1231" AND (WochenTagNum = 1 OR WochenTagNum = 2 OR WochenTagNum = 3) THEN KalenderWoche = 1
IF Middle(LastActiveDate, 5, 4) = "0101" AND (WochenTagNum = 5 OR WochenTagNum = 6 OR WochenTagNum = 7) THEN KalenderWoche = IntegerToWeekNumber(DateToInteger(LastActiveDate)-1)
IF Middle(LastActiveDate, 5, 4) = "0102" AND (WochenTagNum = 6 OR WochenTagNum = 7) THEN KalenderWoche = IntegerToWeekNumber(DateToInteger(LastActiveDate)-2)
IF Middle(LastActiveDate, 5, 4) = "0103" AND WochenTagNum = 7 THEN KalenderWoche = IntegerToWeekNumber(DateToInteger(LastActiveDate)-3)

Kind regards,
Guenter






Edited 2 time(s). Last edit at 12/27/2008 11:36AM by Jimbo.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: