从两个TextBox和Cal差异获得数天 [英] Get No of Days From Two TextBox and Cal Difference
问题描述
在我的databasae表格中,我必须列出
一个用于issueDate的coloumn和一个用于leaveDate
i从数据库获取issueDate和LeaveDate在文本框中显示它们
但是问题是
i想要上天没有
例如
< br $> b $ b发行日期= 12/12/20
请假日期= 12/10/2013
reamin = 12 -10 = 2
i想要告诉我如何只从文本框中获取数天并计算出差异??????????? div class =h2_lin>解决方案
首先,花时间跨度:
System.DateTime issue = // ...
System.DateTime leave = System.DateTime.Now; // 例如
System.TimeSpan duration = leave - issue; // 完整信息现在您可以获得时间跨度的任何方面你想要的,例如:
http://msdn.microsoft.com/en-us/library/system.timespan.days(v = vs.110).aspx [ ^ ],
http://msdn.microsoft.com/ en-us / library / system.timespan.totaldays(v = vs.110).aspx [ ^ ](注意区别)。
另请参阅: http://msdn.microsoft.com/ EN-US /库/ SYST em.datetime%28v = vs.110%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.timespan%28v=vs.110%29.aspx [ ^ ]。
-SA
Timespan
班级 [ ^ ]是要走的路。
in my databasae table i have to coloumn
one coloumn for issueDate and one for leaveDate
i get issueDate and LeaveDate from database and show them in textbox
But the problem is
i want to get on no of days
for example
issue date =12/12/2014
leave date=12/10/2012
reamin=12-10=2
i want this kindly tell me how i can get only only days from textbox and calculate there difference??????????
First, take the time span:
System.DateTime issue = //... System.DateTime leave = System.DateTime.Now; // for example System.TimeSpan duration = leave - issue; // full informationAnd now you can get whatever aspect of the time span you want, in whatever units, for example:
http://msdn.microsoft.com/en-us/library/system.timespan.days(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.timespan.totaldays(v=vs.110).aspx[^] (note the difference).
See also: http://msdn.microsoft.com/en-us/library/system.datetime%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.timespan%28v=vs.110%29.aspx[^].
—SA
The Timespan
class [^]is the way to go.
这篇关于从两个TextBox和Cal差异获得数天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!