Determines whether a string is a valid time function.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.