Oracle Date Format Regular Expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the best way to validate that a date entered into a V/B .net textbox is in the proper format to be converted into an Oracle Date format? (e.g. DD-MON-YYYY.) I don't care about the time portion. I am using this:
^\d{2}(-)(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(-)\d{4}$
but the problem is that it is not specific enough. For example, 44-MAR-2004 is acceptable/matched. I would like to restrict the first 2 digits to what is appropriate for the month, e.g. no greater than 31 in this case. Leap year logic would be good also.

Can anyone point me to a regular expression that they know about that works for this purpose, and that will also run properly in .net? I need a specific routine that someone out there uses and is comfortable with, rather than a URL to a general Regular Expression Web Site.

T H A N K S ! ! !
 
Luke

Thanks for your quick reply. Your links to more information about regular expressions have convinced me that using regular expressions is probably the wrong approach, as no one expression can really give me a perfect and complete date edit, and I can't take a chance on a bad date slipping past my edit. A co-worker suggested using a Compare Validator with the type set to date and the operator set to DataTypeCheck. What do you think of this approach? The only problem is that the format for my dates will now be MM/DD/YYYY which is not what the users are used to. Is there any way that a Date based DataTypeCheck can use a DD-MON-YYYY format, similar to Oracle? (Ideally, a variety of choices would be perfect, some sort of list of various format masks to choose from with the option to override what is in the list, in case the list is not complete for some reason.

Thanks

P.D.
 
Hi Paul,

The CompareValidator control doesn't support the format like DD-MON-YYYY.
The Regularvalidator control is still the closest approach for this issue.
Or you may try use three dropdownlist instead of a Textbox, the first is
for date containing 1~31...

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Paul,

The validation is based on the script in
\wwwroot\aspnet_client\system_web\1_1_4322\WebUIvalidation.js. In the
script, it will convert both of string MM/DD/YYYY and MM/DD/YY to a valid
date. I think one Validator control is not enough for this sitatuion. You
may consider add a validator control working with the Compare Validator.
For example, a RegularExpress validator control or a Customvalidator
control. In a customValidator control's client validation script, you can
perform you own validation based on the input string.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Paul,

Thank you for the reply. custom validator control is as easy as other
validator control. You can follow the sample in my reply to your another
post and you will find it is easy to use. It is just more flexible.

Regarding the concern on the validattion data format, if you feel this
need to be improved and will benifit more user, I suggest you may send a
comment or suggestion via our Web, all suggestion and comment will be
considered by our developer before next version is designed. You can visit
the following Microsoft Product Feedback Web site:

http://register.microsoft.com/mswish/suggestion.asp and then complete and
submit the form.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top