Page 1 of 1

Check whether input is of an expected date format

Posted: Thu Dec 18, 2008 3:38 pm
by sumesh.abraham
Hi,

I want to check whether input date field is of expected format for date fields in different files. If I pass the expected length and date format to a routine, will the below example work

Code: Select all

If Len(Arg1)=8 And Not(IsNull(Iconv(Arg2,'DMDY[2,2,4]'))) Then
 Ans=1
End
Else
Ans=0
I've to write the record to an error table if date validation fails.

Does IsValid function check this?

Is there any other solution?

Thanks,
Sumesh

Posted: Thu Dec 18, 2008 3:59 pm
by ray.wurlod
You may need to adapt the IsValid() function (for server) because it is a little more forgiving of date format.

Note also that Iconv() does not return NULL unless the date is actually NULL. You would do better to check the result of the Status() function after applying the Iconv() function.

Did you mean Arg1 to be the argument of Iconv()?