View previous topic :: View next topic
|
Author |
Message |
vidyaa
New User
Joined: 02 May 2008 Posts: 77 Location: chennai
|
|
|
|
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 |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
1. PARSE
2. SIGNAL
O. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
read the manual about the date built in function ( it can be used to check a date - to some extent ) |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
vidyaa
New User
Joined: 02 May 2008 Posts: 77 Location: chennai
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
Back to top |
|
|
|