嗨,如何计算两个日期之内的总时数? [英] hi how to calculate total hours from within two dates?
本文介绍了嗨,如何计算两个日期之内的总时数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi如何编写存储过程以计算日期中的总小时数
例如:
sql表中包含类似dis ..
startDate 1/02/2012
结束日期2012年1月2日
executetime = 6
开始日期2012年2月2日
结束日期2012年2月2日
executetime = 8
...继续直到2012年2月30日
在aspx页面中
现在我想在总时间文本框中计算从1/02/2012到15/02/2012的总时间.如何计算..那?
解决方案
尝试:
SELECT sum(DATEDIFF(hour,startDate,endDate))> FROM 学生位置 startDate BETWEEN ' 2012-02-01' AND ' 2012-02-15'
尝试SELECT DATEDIFF(hh, @ date1 , @ date2 )
创建一个存储过程,该存储过程请求2个日期时间参数,例如@BeginMonth和@EndMonth.
现在您可以将DateDiff(hh,startdate,endDate)设置为Hoursworked
在(@BeginMonth和@EndMonth)之间的起始日期
只需在存储过程中添加魔术方块With Cube,并在要求的时间内将显示小时数的所有天加起来即可.
hi how to write stored procedure to calculate total hours from dates
for example:
in sql table contains like dis..
startDate 1/02/2012
enddate 1/02/2012
executiontime=6
startdate 2/02/2012
enddate 2/02/2012
executiontime=8
...continue til 30/02/2012
in aspx page
now i want to calculate for total hours from 1/02/2012 to 15/02/2012 in total hours textbox .how to calculate.. that?
解决方案
Try:
SELECT sum(DATEDIFF(hour, startDate, endDate)) FROM Student WHERE startDate BETWEEN '2012-02-01' AND '2012-02-15'
TrySELECT DATEDIFF(hh, @date1, @date2)
create a stored procedure that requests 2 datetime parameters like @BeginMonth and @EndMonth.
Now you can do a DateDiff(hh, startdate, endDate) as Hoursworked
where startdate between (@BeginMonth and @EndMonth)
Just add the magic line With Cube to your stored procedure and all days in the requested period where hours are shown for are also summed.
这篇关于嗨,如何计算两个日期之内的总时数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文