Rexx Exec : ISDATE

Navigate back to home page
z/OS related collateral
Windows related collateral
SQL/mySQL related collateral
Link to code that can be used on websites.
Link to ASL Program Documentation
All our latest news
Contacting Abbydale Systems
Obtain product support/suggestions
https://www.abbydalesystems.com/Terms and con
General disclaimer
All about Abbydale Systems
How we got our company name
Our privacy policy
Our development strategy
Visit our guestbook

As ever, you use this free program at your own risk.

Feel free to use the free software on this site but please honor the copyright.

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 document. 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 separated 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 are:

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



This material has been used successfully by Abbydale Systems LLC. and to the best of our knowledge this material and any system(s) of which it is a part are operational as of the service level or date stated in the body of this material (if so stated). However, NO warranty is given or implied as to the accuracy of this material or any related material or systems, and no responsibility is assumed for any effect or modification directly or indirectly caused by the use of this material.

It is the responsibility of any user of this material to evaluate its usefulness to the user's environment.

Abbydale Systems LLC. does not guarantee to keep this or any related material current, nor does it guarantee to provide any corrections or extensions described by any users of this material or any corrections or extensions made in the future by Abbydale Systems LLC. itself.


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

follow us on facebook
Follow us on Facebook




Subscribe to our YouTube Channel Subscribe to our YouTube channel


CBT Tape Home Page MVS and OS/390 Freeware Link to the CBT website


Copyright © Abbydale Systems LLC 2015-2026

Abbydale Systems LLC Lic. 802696149. All rights reserved.