From: Ne Scripter Date: 2009-09-01T22:04:48+09:00 Subject: Date & time validation Hi all, I am looking for an easy way to validate date and time values in a script I have written. The script takes values from a large file containing various data sets, some dates and some times. I need to validate these dates and time values once I have loaded them into a variable and I was thinking of doing this through an a date check and time check object for example: date1 = field[2] date1 = dateCheck(date1) if date1 != "" date2 = field[23] date2 = dateCheck(date2) if date2 != "" time = field[24] time = timeCheck(time) if time != "" def dateCheck(dateData) I need some code to check what ever is in this string and check for a valid date of yyyy/mm/dd. The data being checked can be anything, so I need to know does it match the date format of yyyy/mm/dd, if so return true otherwise return an empty string end def timeCheck(timeData) similar idea with the time I need to check the data is hh:mm:ss otherwise return an empty string. end Any ideas on how to do this? I was looking a the docs for date and I am struggling to make head way at this stage. Thanks in advance! -- Posted via http://www.ruby-forum.com/.