如何计算两次之间的差异 [英] How to calculate difference between two times
本文介绍了如何计算两次之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在使用带有sql server数据库的基于Web的应用程序进行办公室管理.在这里,我有一个分支计时页面.它包含两个分别用于``输入时间''和``输出时间''的文本框.
在第一个文本框中(按时间)-上午10:00
在第二个Tex框中(超时)-04:30 PM
我需要得到的总工作时间是06:30.
我该如何计算呢??
请帮我解决这个问题????
Hi all,
I am doing a web based application with sql server database for office management.In this i have one branch timing page.It contain two text boxes for ''in time'' and ''out time'' respectively.
In the first text box (in time)-- 10:00 AM
In the Second Tex box (out time)-- 04:30 PM
The result i need to get for the total working hours is 06:30 .
How can i calculate this???
Plz help me to solve this problem???
推荐答案
当有一些非常有用的日期时间控件可用时,为什么要使用文本框?两个这样的控件将为您提供DateTime
值,然后您可以使用它们来计算TimeSpan
从而为您提供所需的信息.
Why are you using text boxes, when there are some perfectly useful datetime controls available? Two such controls will give youDateTime
values which you can then use to calculate aTimeSpan
giving you the information you need.
首先,将文本框的值转换为DateTime显然,同一日期的格式具有不同的时间.然后减去2个日期.总计将是一个时间戳记对象,您可以从那里获取总时数.请参见此处 [
First, convert the values of the textbox to a DateTime format of the same date, with different time, obviously. And then subtract the 2 dates. The total will be a timestamp object, which from there you can get the total hours. See here[^] for more details.
这篇关于如何计算两次之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文