It is often desirable to validate that a user entered date is a valid date. There is really no 'out of the box' solution to this.

There are, of course, some ISPF validation methods within ISPF panel definitions although these are fairly rudimentary and somewhat error prone, checking mainly for syntax rather than validity.

ISDATE is our solution to this issue.

ISDATE is a Rexx exec that will, not only check to see if a passed date is in a correct format, but will also check the validity of the date. For example: that the number of days in the month is not exceeded.

We have intentionally limited the allowed year to only process years after 1753 the reason for this is explained on our Zeller's congruence webpage. We assume that (unlike Excel) most of the time the mainframe is used for serious business rather than just for 'fun'. Thus we see no need to make it support dates before 1753!

So how does ISDATE work and how do you use it?


The format of the call to ISDATE is:
ISDATE(DateToTest,DateFormatToUse)

  DateToTest Specifies the string to be checked for a valid date. The string, unless it is DATE() format, must have the days, months and years seperated by a forward slash (/). i.e. 12/23/2021

By DATE() Format we mean in Local Date format as specified by Rexx (DD MMM YYYY) i.e 25 JAN 1999

 
  DateFormatToUse This is an optional parameter which can be used to change the default format from MMDDYYYY

The supported values are:
  • DDMMYYYY
  • MMDDYYYY - This is the default.
  • YYYYDDMM
  • YYYYMMDD
(Note: The date formats do not contain forward slashes)

It should be noted also that if the local time format is being used, then DateFormatToUse will be ignored as DDMMYYYY will be used to validate the date.
 
Return Codes From ISDATE
  0 - Date is valid
4 - Help displayed
8 - Date is invalid
12 - Incorrect date format
 
Sample Calls
  say "try "date()
mydate = date()
rc = isdate(mydate)
if rc > 0 then do
   say mydate "is not a valid date"
end
else do
   say mydate "is a Valid date"
end
say "try 01/29/1964"
mydate = "01/29/1964"
rc = isdate(mydate)
if rc > 0 then do
   say mydale "is not a valid date"
end
else do
   say mydate "is a Valid date"
end
say "try 02/29/2004"
rc = isdate("02/29/2004")
if rc > 0 then do
   say "02/29/2004 is not a valid date"
end
else do
   say "02/29/2004 is a valid date"
end
say "try 2000/2/29"
rc = isdate("2000/2/29",'yyyymmdd')
if rc > 0 then do
   say "2000/2/29 is not a valid date"
end
else do
   say "2000/2/29 is a valid date. Leap year"
end
say "try 29/2/1900"
rc = isdate("29/2/1900",'ddmmyyyy')
if rc > 0 then do
   say "29/2/1900 is not a valid date"
end
say rc
 
Resulting Output
  try 22 Jan 2022
22 Jan 2022 is a Valid date
try 01/29/1964
01/29/1964 is a Valid date
try 02/29/2004
02/29/2004 is a valid date
try 2000/2/29
2000/2/29 is a valid date. Leap year
try 29/2/1900
29/2/1900 is not a valid date
8
 
ISDATE is available from the top menu under "z/OS Based Software Inventory" or from here.

It is also available directly from here.
 
 


If you need any support or assistance with any of the code on this site
or
if you would like to contact us, please click here

follow us on facebook
Follow us on Facebook

 

Number of unique visitors 374

Copyright © Abbydale Systems LLC 2015-2024

Abbydale Systems LLC Lic. 802696149. All rights reserved.

Last modified : Saturday 22nd of January 2022