Last change 2017.08.06 19:54:19 / Time 2025.11.07 13:18:14
My own ISPF hints and tips
(As of 2007.07.26 21.17)
As requested, REXX code to convert yyyyddd to yyyymmdd. Note that the
input date is not validated...you will have to add your own code to
do that.
JUL2GREG:Procedure
yyyyddd = arg(1) /* get the passed argument */
yyyy = substr(yyyyddd,1,4) /* get the years (4-digit) */
ddd = substr(yyyyddd,5,3) /* get the days */
cc = substr(yyyyddd,1,2) /* get the century */
yy = substr(yyyyddd,3,2) /* get the years (2-digit) */
leap = 0 /* assume not leap year */
/* Decide if yyyy is a leap year */
if yyyy/4 = trunc(yyyy/4) then leap = 1
if (yy = "00") & (cc/4 <> trunc(cc/4)) then leap = 0
/* Now set up a stem containing the number of days in the year */
/* for each month (Jan (1) to Dec (12))
daysinyr.0 = 12 /* Number of elements in stem */
daysinyr.1 = 0 /* Number of days so far ... */
daysinyr.2 = 31
daysinyr.3 = 59
daysinyr.4 = 90
daysinyr.5 = 120
daysinyr.6 = 151
daysinyr.7 = 181
daysinyr.8 = 212
daysinyr.9 = 243
daysinyr.10 = 273
daysinyr.11 = 304
daysinyr.12 = 334
/* Adjust the stem values for Mar onwards by adding the value */
/* of 'leap'. For non-leap years this will do nothing... */
i = 3 /* Start at March */
do 10 /* Adjust the 10 months */
daysinyr.i = daysinyr.i + leap /* Add 'leap' value */
i = i + 1 /* next month... */
end
/* go thru the months and calculate the month and day values */
i = 12 /* Start at Dec */
do 12 /* Go thru all months */
if ddd > daysinyr.i then do /* if we are in this month.. */
mm = right(i,2,0)
dd = right(ddd - daysinyr.i,2,0)
leave /* leave loop */
end
i = i - 1 /* go back a month */
end
yyyymmdd = yyyy!!mm!!dd /* join mm and dd to yyyy */
return yyyymmdd
(As of 2007.07.26 21.22)
With OS/390 the REXX date() function was enhanced.
You can try this:
/* convert yyddd to yymmdd */
say space(translate(date("O","97059","J"),,"/"),0)
(As of 2007.07.26 21.25)
I've noticed that you said to use Zmsg000s and Zmsg000l
while most everyone else said to use ZEDSMSG and ZEDLMSG.
Yours worked for me while theirs did not. Is this a release
dependent thing? We're not running OS/390 yet.
The difference is that when using the variables ZEDSMSG and ZEDLMSG
the message id for SETMSG should be ISRZ00, not ISPZ00.
(As of 2007.07.26 21.26)
With OS/390 the REXX date() function was enhanced.
You can try this:
/* convert yyddd to yymmdd */
say space(translate(date("O","97059","J"),,"/"),0)