© serviceprofessionalgmbh

Quite often the power of the MVS REXX date function is underrated or the manual simply is not studied in great detail (which was not really possible in earlier days).

Summarised the DATE function allows the conversion of a date in most formats into most other format. Date calculations are also possible at conversion time (please refer to Calculation dates).

In our homebase Germany dates are usually referred to in the format of tt.mm.jjjj.
As this format is not supported directly by REXX, we define the date format in the program as G (German).

Also the conversion to JULIAN is not supported. Therefore have a look at DN2DJ (Date Normal TO Date Julian)

/* REXX * XDATE
*/
parse source . PTYP .
if PTYP = "FUNCTION" then arg FMT_OUT,BASE_DATE,FMT_IN,DUMMY
else                      arg FMT_OUT BASE_DATE FMT_IN .
SAVE_FMT_OUT = FMT_OUT
if FMT_IN = "G" then do                     /* Input-Format = GERMAN */
   parse var BASE_DATE TT "." MM "." JJJJ
   BASE_DATE = JJJJ !! MM !! TT             /* change to SORTED      */
   FMT_IN    = "S"                          /* change to SORTED      */
end
if FMT_OUT = "G" then do                    /* change to SORTED      */
   FMT_OUT = "S"
end
NEW_DATE = date(FMT_OUT,BASE_DATE,FMT_IN)
if SAVE_FMT_OUT = "G" then do
   parse var NEW_DATE 1 JJJJ 5 MM 7 TT
   NEW_DATE = TT"."MM"."JJJJ                /* change to GERMAN      */
end
return NEW_DATE
back to Date & Time