Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
2
Erster Beitrag:
vor 9 Jahren, 2 Monaten
Letzter Beitrag:
vor 9 Jahren, 2 Monaten
Beteiligte Autoren:
Jimbo, PETER ZHOU

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

Startbeitrag von PETER ZHOU am 27.12.2008 09:41

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

Antworten:

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

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




von Jimbo - am 27.12.2008 10:30
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.