问:
我要得到两个时间的差的小时数,怎么实现。
比如:2003-01-02 10:20:30
2003-01-03 13:30:20
______________________________________________________________________________________________
答1:
SQL语句中:
select DATEDIFF(hour, Coordinate.OperateTime, GETDATE()) AS HourDiff
______________________________________________________________________________________________
答2:
.Net中:
DateTime time1=your time1;
DateTime time2=your time2;
TimeSpan ts=time2-time1;
则ts.TotalHours为所需的小时数(double型带小数)