Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Date Validations using Regex

user8604857Mar 16 2016 — edited Mar 16 2016

Hello All


I am running into an issue for Date validation as I am not able to get the desired bad dates out. The dates are in YYMMDD (VARCHAR2) format.

The last two dates are not failing.

. I would appreciate if any one of you expert can help in resolving this. The Date columns are repeated multiple time in my table.

SQL*Plus: Release 11.2.0.1.0 Production on Thu Feb 4 09:31:26 2016
Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing option

WITH Src

     AS (SELECT '001212' Dt FROM DUAL

         UNION

         SELECT '1$1212' Dt FROM DUAL

         UNION

         SELECT '1212#2' Dt FROM DUAL

         UNION

         SELECT '150231' Dt FROM DUAL

          UNION

         SELECT '150431' Dt FROM DUAL)

SELECT *

FROM  Src

WHERE NOT REGEXP_LIKE (Dt, '^([0-9]{2})(0[1-9]|1[0-2])([012][1-9]|10|20|30|31)$')

I know there are lots of places dates are validated if any body can help me in resolve in validating the date..

Thanks in Advance.

Rajesh

This post has been answered by CarlosDLG on Mar 16 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 13 2016
Added on Mar 16 2016
5 comments
1,926 views