I don't see how we could check for leap years, though, as long as the regular expression has to fit in a VARCHAR2.īut even that assumes that your string is actually a consistent format that meets your assumptions of 'mm/dd/yyyy'. With even more work, we could check that 'DD' is never '31' for April, June, etc., and that it's not '30' for February. With a little more more work, we could make sure that 'MM' was between '01' and '12', and that 'DD' was always between '01' and '31'. Using just a regular expression, we could easily check that the string is in 'MM/DD/YYYY' format, though 'DD' might be '99'. We'd have to combine a regular expression (or multiple exprdssions) with something else. Using only a regular expression (any REGEXP function now available in Oracle), we can't check for all possible mistakes. I agree but let's say this is a purely academic question, not something we plan to use in actual Production code. Oh, and by the way - I still stand by my statement that you cannot validate a string is a valid date with a regular expression Make use of the tools you have - no need to reinvent the wheel.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |