Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

To check for a valid date

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
vidyaa

New User


Joined: 02 May 2008
Posts: 70
Location: chennai

PostPosted: Wed Jul 09, 2008 4:20 pm    Post subject: To check for a valid date
Reply with quote

Hi,

can anybody tell me how do we check if the date entered in the MM/DD/YYYY format is a valid date or not(including the leap years)

ex: 01/02/2008 -- valid
14/01/2008 -- invalid
02/29/2008 -- valid(leap year)
02/29/2007 -- invlaid

please let me know your suggessions
Back to top
View user's profile Send private message

ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Wed Jul 09, 2008 4:40 pm    Post subject:
Reply with quote

1. PARSE
2. SIGNAL

O.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10232
Location: italy

PostPosted: Wed Jul 09, 2008 5:04 pm    Post subject: Reply to: To check for a valid date
Reply with quote

read the manual about the date built in function ( it can be used to check a date - to some extent )
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1226
Location: Israel

PostPosted: Wed Jul 09, 2008 5:31 pm    Post subject:
Reply with quote

That's a problem, because REXX does not recognize this date format (check the manual)
I would reformat the date then check it with the DATE function:
Code:
Valid_Date: procedure                             
   parse arg chkdate                                 
   wdate = translate("56781234",chkdate,"12/34/5678")
   signal on SYNTAX  name Valid_Date_Trap
   wres = Date(,wdate,'S')                           
   signal off SYNTAX                                 
return(1)                                           
Valid_Date_Trap:                                         
Return(0)

then you can use:
Code:
If Valid_Date("02/29/2007") = 0 then say "date no good!"
if Valid_Date("02/29/2008") = 1 then say "all right!"
Back to top
View user's profile Send private message
vidyaa

New User


Joined: 02 May 2008
Posts: 70
Location: chennai

PostPosted: Thu Jul 10, 2008 11:54 am    Post subject:
Reply with quote

Thank you so much marso this works perfect

in the command
translate("56781234",chkdate,"12/34/5678")

If i change the order of these numbers this doesnot work
so can you please tell me the significance of this statement what is that exactly doing.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10232
Location: italy

PostPosted: Thu Jul 10, 2008 12:11 pm    Post subject: Reply to: To check for a valid date
Reply with quote

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ3A320/4.3.64?SHELF=IKJOSE20&DT=20000113164209

the link posted points to the manual description of the REXX translate built in function

should be easy to understand its working

anyway is a way of rearranging a string content
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts How to get current date -1 and curren... murali.andaluri DFSORT/ICETOOL 3 Wed Mar 08, 2017 2:09 pm
No new posts Overlay the system date Danielle.Filteau SYNCSORT 4 Fri Mar 03, 2017 1:16 am
No new posts Checking Current date vickey_dw DFSORT/ICETOOL 1 Wed Feb 08, 2017 11:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us