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: 10211
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: 1224
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: 10211
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 What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm


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