Sunday, May 5, 2013

function to check for date format in mm/dd/yyyy


********************************************************
 'function to check for date format in mm/dd/yyyy
 '*******************************************************
Function  fnDateFormat(strdate)
Set regEx = New RegExp
datePattern = "((0[1-9]|1[0-2])0[1-9]|[12][0-9]|3[0-1])/([0-9]{4})"
'Set pattern.
regEx.Pattern = datePattern
'Ignore case
regEx.IgnoreCase = True
'Match complete string or not
regEx.Global = MatchCompleteString

'Test the regular expression
IsRegEqual = regEx.Test(strdate)
Set regEx = Nothing
fnDateFormat=IsRegEqual
End Function

No comments:

Post a Comment