Sybase ASE 判断字符串是否为日期和数字的两个函数
Sybase ASE自版本15.0.2开始增加判断字符串是否为日期类型的函数:isdate,以及判断字符串是否为数字类型的函数:isnumeric
函数:isdate
Syntax
isdate(character_expression)
Parameters
character_expression
is a character-type variable, constant expression, or column name.
Usage
Returns 1 if the expression is a valid datetime value; returns 0 if it is not. Returns 0 for NULL input.
例子:
1> select isdate('12/21/2005')
2> go-----------
1(1 row affected)
1> select isdate('12212005')
2> go-----------
0(1 row affected)
1> select isdate('20050228')
2> go-----------
1(1 row affected)
1> select isdate('20050229')
2> go-----------
0(1 row affected)
函数:isnumeric
Syntax
isnumeric (character_expression)
Parameters
character_expression
is a character-type variable, constant expression, or a column name.
Usage
* Returns 1 if the input expression is a valid integer, floating point number, money or decimal type; returns 0 if it does not or if the input is a NULL value. A return value of 1 guarantees that you can convert the expression to one of these numeric types.
* You can include currency symbols as part of the input.
例子:
1> select isnumeric("$100.12345")
2> go-----------
1(1 row affected)
1> select isnumeric("-0.001")
2> go-----------
1(1 row affected)
1> select isnumeric("¥123")
2> go-----------
0(1 row affected)
1> select isnumeric("123,456.001")
2> go-----------
1(1 row affected)