1、文法
datediff(datepart,startdate,enddate)
datepart的值可以是以下:
datepart | 縮寫 |
---|---|
年 | yy, yyyy |
季度() | qq, q |
月 | mm, m |
年中的日 | dy, y |
日 | dd, d |
周 | wk, ww |
星期 | dw, w |
小時 | hh |
分鐘 | mi, n |
秒 | ss, s |
毫秒 | ms |
微妙 | mcs |
納秒 | ns |
celling(numeric_expression ) 傳回大于或等于所給數字表達式的最小整數。
http://technet.microsoft.com/zh-cn/library/ee634541(v=sql.105).aspx celling用法
例:
select tel,begindate,enddate,isnull(datediff(second,begindate,enddate),0) as 按秒計時長, isnull(celling(convert(float,datediff(second,begindate,enddate),108)/60),0) as 按分鐘計時長 from TelRecord