Kbase 13496: How to initialize 12 DATE fields to last days of the month
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
How to initialize 12 DATE fields to last days of the month
This program example shows a way to define a DATE variable as an array
and then initialize it to the last days of the months, for example:
d[1] = "01/31/94"
d[2] = "02/28/94"
d[3] = "03/31/94"
d[4] = "04/30/94"
: :
: :
The trick is to set the date variable to the first day of the
*following* month, then subtract one. Since date variables do not
allow a month numbered 13, the program checks for this case and makes
an allowance for it.
This program will also work with leap years.
DEF VAR d AS DATE EXTENT 12 FORMAT "99/99/99".
DEF VAR i AS INTEGER.
DEF VAR j AS INTEGER FORMAT "9999".
j = 1994. /* set year */
DO i = 2 TO 13:
IF i <> 13 THEN d[i - 1] = DATE(i,1,j) - 1.
ELSE d[12] = DATE(1,1,j + 1) - 1.
END.
DISPLAY d WITH FRAME f.
Progress Software Technical Support Note # 13496