Forgotten:
vjaar is also a input value (vjaar = Dutch for vyear)
----- Original Message -----
From: Jouke Hendrik de Vries <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 24, 2001 10:30 PM
Subject: Getting start and end days from a given weeknumber
> I developped a small routine that calculates start and end dates from a
> given weeknumber. Maybe usefull.
>
> VAR vweekn is a INPUT value
> DIACMD is just a messaging routine
> In this routine SUNDAY is set as the first day af the week, saturday as
the
> last day
> Values that exceed 53 are not valid (first block)
> When vweekn = 53, then a validation is performed --> does this year
actually
> have 53 weeks?
> If not, the week 1 of the next year is automatically set.
> Just works like a charm (for me)
>
> Today I converted this routine into a Progress application. Major
> disappointment: Progress does not even know DATETIME formats and
recognises
> time values only in INTEGER format. Just appreciating R:Base more and
more.
> Easy, forgiving and allows you to be very creative.
>
> $COMMAND
> WEEKCMD
> IF vweekn > 53 THE
> SET VAR diameld TEXT = (CTR("Valid weeknumber max = 53 ";50))
> SET VAR dtoets TEXT=(CTR("Press any key...";50))
> RUN DIACMD IN PLANAPP.APX USI 11 diameld dtoets
> CLE VAR diameld dtoets vweek2 vjaar vjaar2 vlijn vsdate +
> vedate vint1 vint2 diatext diaint vtext
> SET VAR vweekn = NULL
> ENDI
> IF vweekn IS NOT NULL THE
> SET VAR vyr INT = .vjaar
> SET VAR vjan1txt TEXT = ("01/01/" + (CTXT(.vyr)))
> SET VAR vjan1dat DATE = .vjan1txt
> SET VAR vjan1int INT = (IDWK(.vjan1dat))
> SET VAR vstweek DATE = +
> (IFGT(vjan1int;0;(IFLT(vjan1int;5;((vjan1dat+1)-vjan1int);+
> (vjan1dat+(8-vjan1int))));(vjan1dat+(8-vjan1int))))
> SET VAR vsdate DATE = (vstweek + (vweekn*7-8))
> SET VAR vedate DATE = (vsdate + 6)
> IF vweekn = 53 THE
> SET VAR vyr2 INT = (vyr + 1)
> SET VAR vjan2txt TEXT = ("01/01/" + (CTXT(.vyr2)))
> SET VAR vjan2dat DATE = .vjan2txt
> SET VAR vjan2int INT = (IDWK(.vjan2dat))
> IF (vjan2dat - vsdate + 1) < 5 THE
> SET VAR diameld TEXT = (CTR("This year does NOT have 53 weeks";50))
> SET VAR dtoets TEXT=(CTR("Press any key...";50))
> RUN DIACMD IN PLANAPP.APX USI 11 diameld dtoets
> CLE VAR diameld dtoets vweek2 vjaar2 vlijn vsdate +
> vedate vint1 vint2 diatext diaint vtext
> SET VAR vweekn INT = 1
> SET VAR vyr = (vyr + 1)
> ENDI
> ENDI
> ENDI
> RECALC VAR
> RETURN
>