Determines whether a string is a valid time function.
A function used to determine whether a string is a valid time. If it is a valid time, 1 is returned. If it is not a valid time, 0 is returned.
CREATE OR REPLACE FUNCTION is_date(parameter VARCHAR2) RETURN NUMBER ISval DATE;BEGINval := TO_DATE(NVL(parameter, 'a'), 'yyyy-mm-dd hh24:mi:ss');RETURN 1;EXCEPTIONWHEN OTHERS THENRETURN 0;END;
For specific examples, you can directly use:
alter session force parallel ddl parallel 8;create table TT as select t.id,floor(months_between(sysdate,to_date(t.birthday,'yyyymmdd'))/12) agefrom TT_WXTRAN twhere is_date(t.birthday)!=0;
Function used by excel to determine whether a character exists in a string
FIND
Assume that your string is in A1. check whether the string contains the "B" character.
= IF (ISERROR (FIND ("B", A1), "NONE", "yes ")
Is there a function in java to directly determine whether a date represented by a string, such as "2010-02-31", exists, and return a Boolean value?
// Very simple.
Public static void main (String [] args ){
System. out. println (isDateExist ("2010-02-31 "));
}
Public static boolean isDateExist (String dtStr) {// 2010-02-31
SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd ");
Date d = null;
Try {
D = sdf. parse (dtStr );
} Catch (ParseException e ){
E. printStackTrace ();
}
String result = sdf. format (d); // determine whether the two strings before and after conversion are equal.
Return result. equals (dtStr );
}
References: if you have other questions, send me a Baidu message.