strsql = "select datediff('h',CONVERT(varchar(100), cls_end_time, 20),CONVERT(varchar(100),cls_start_time, 20)) as time from classes where cls_num= '" + txtClsNum1.Text.Trim + "'"我想求兩個時間相隔多少小時多少分,不需要秒。返回 1.2 1.6 2.3 之類的數字即可。。這與據要怎么寫才好?System.Web.Services.Protocols.SoapException: 伺服器無法處理要求。 ---> System.Exception: ErrorIndex #0
Message: Invalid parameter 1 specified for datediff.
NativeError: 1023
Message: Invalid parameter 1 specified for datediff.
NativeError: 1023
小时
--------------------
7.166666(所影响的行数为 1 行)
**/
select convert(float(1),round(datediff(mi,'2009-03-17 12:00:20',getdate())*1.0/60,1)) as [时间(h)]
select cast(datediff(mi,'2009-03-17 12:00:20',getdate())*1.0/60 as dec(18,1)) as 小时/**
小时
--------------------
7.5(所影响的行数为 1 行)
**/