right(字段名,n)
sql从右侧截取字符串。n代表从右侧截取的位数。
SELECT
RIGHT(‘123456‘, 4)
SELECTLEFT(‘123456‘, 4)
--------------------------------------------------------------
举个栗子:
declare
@starttime
as
datetime
declare
@endtime
as
datetime
set
@starttime
=
GETDATE()--‘2018-06-19 17:08:02.000‘ set@endtime=‘2018-06-20 17:08:02.000‘selectright(‘00‘+cast(cast(datediff(ss ,@starttime,@endtime) /3600asint) asvarchar),2) +‘:‘+right(‘00‘+cast(cast(datediff(ss ,@starttime,@endtime) %3600/60asint) asvarchar),2) +‘:‘+right(‘00‘+cast(cast(datediff(ss ,@starttime,@endtime) %60asint) asvarchar),2)
原文:https://www.cnblogs.com/lpl521/p/9202228.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!