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!

Function check valid date

Shadow123May 1 2016 — edited May 4 2016

Oracle 11g

Hi All

I appreciate if someone help me out, my requirement is that to create a function that will accept a value and check that this value  should be date format and  if yes then return true other wise return  false. So far, I created the below function but its not working...

Code for function

FUNCTION is_valid_date_format (

    p_format IN date )

RETURN BOOLEAN IS

    l_date VARCHAR2(100) := NULL;

BEGIN

    l_date := TO_char( p_format, 'MON-YYYY' );

    RETURN TRUE;

EXCEPTION

    WHEN OTHERS THEN

        RETURN FALSE;

END is_valid_date_format;

---Function execution

SELECT is_valid_date_format(TO_DATE('APR-2016','MON-YYYY') ) FROM DUAL;

Error

ORA-06552: PL/SQL: Statement ignored

ORA-06553: PLS-382: expression is of wrong type

06552. 00000 -  "PL/SQL: %s"

*Cause:   

*Action:

Error at Line: 5 Column: 12

Please guide.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 1 2016
Added on May 1 2016
23 comments
26,818 views