您的位置:首页 > 其它

第三节 字符串函数、日期函数、数学函数等

2012-06-24 10:14 99 查看
View Code

--字符串函数:

--返回指定字符串的索引,索引从开始,返回一个索引(int类型)

selectcharindex('niit','Welcome to niit')

selectcharindex('niit','Welcome to niit',8)

--返回字符串的长度(返回字符个数非字节个数)

selectlen('SQLServer2005编程')

--将大写字符串转换为小写

selectlower('SQLSERVER')

--清除字符左边空格

selectltrim('      SqlServer')

--从字符右边开始取多少个字符

selectright('买卖提.吐尔松',3)

--从字符左边开始取多少个字符

selectleft('买卖提.吐尔松',3)

--字符串替换

selectreplace('买卖提.吐尔松.','.','*****')

--截断后插入

selectstuff('ABCDEFG',2,3,'我的音乐,我的世界')

--日期函数

--获取当前系统日期

selectgetdate()

--对当前指定时间部分添加

selectDateAdd(year,3,getDate())

selectDateAdd(year,3,'2015-3-1 13:15:22.500')

selectDateAdd(yy,3,'2015-3-1 13:15:22.500')

selectDateAdd(month,2,getDate())

selectDateAdd(month,-2,getDate())

--时间差函数(根据指定的datepart参数返回差值)

selectDateDiff(month,'2012-1-1',getdate())

selectDateDiff(hour,'2012-1-1',getDate())

--返回指定时间的部分信息(返回值为字符)

selectDateName(wk,getDate())

selectDateName(yy,getDate())

selectDateName(quarter,getDate())

--返回指定时间的部分信息(返回值为整型)

selectDatePart(wk,getDate())

--数学函数

--取绝对值

selectabs(-43)

--取数值表达式的幂值

selectpower(5,3)

--四舍五入

selectround(5.55555,2)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐