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
date1 = dateCheck(date1) if date1 != “”
date2 = field
date2 = dateCheck(date2) if date2 != “”
time = field
time = timeCheck(time) if time != “”
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
similar idea with the time I need to check the data is hh:mm:ss
otherwise return an empty string.
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!