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)

 

 

 

    

  • 本文链接地址:http://www.sybrepair.com/sybase-ase-15_0_2-function-isdate-isnumeric.htm
  • 本文为dbainfo个人原创,请在尊重作者劳动成果的前提下进行转载;
  • 转载务必注明原始出处 : Sybase数据库技术,数据库恢复专家
  • 对《Sybase ASE 判断字符串是否为日期和数字的两个函数》有何疑问或见解,请在本文下方发表;
  • 对网站还有其他问题或建议,请提交在留言板,谢谢!
  • 目前还没有任何评论.
    :wink: :twisted: :roll: :oops: :mrgreen: :lol: :idea: :evil: :cry: :arrow: :?: :-| :-x :-o :-P :-D :-? :) :( :!: 8-O 8)