IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

To check for a valid date


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vidyaa

New User


Joined: 02 May 2008
Posts: 77
Location: chennai

PostPosted: Wed Jul 09, 2008 4:20 pm
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: 2358
Location: Israel

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

1. PARSE
2. SIGNAL

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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jul 09, 2008 5:04 pm
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: 1353
Location: Israel

PostPosted: Wed Jul 09, 2008 5:31 pm
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: 77
Location: chennai

PostPosted: Thu Jul 10, 2008 11:54 am
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jul 10, 2008 12:11 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts SCOPE PENDING option -check data DB2 2
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top