Funktion WEEKIS8601 in Clipper

Berechnung der Kalenderwoche nach ISO 8601

funktioniert ab dem 4.1.0100 bis und mit 29.12.2999

FUNCTION WEEKIS8601(datum)
LOCAL firstdate := DATE()
LOCAL kalwoche  := 0
LOCAL neudatum  := DATE()
LOCAL resttage  := 0
LOCAL wochentag := 0
IF VALTYPE(datum)=="D"
	wochentag=DOW(datum)+5
	resttage =wochentag-(INT((wochentag+0.1)/7)*7)
	neudatum =datum+3-resttage
	firstdate=CTOD("01.01."+STR(YEAR(neudatum),4,0))
	kalwoche =1+INT((neudatum-firstdate+0.1)/7)
ENDIF
RETURN(kalwoche)

 

© 2004 EDV-Beratung L. Heitz