如何计算Asp.Net中的未来日期 [英] How to calculate the Future Date in Asp.Net
问题描述
我有一个ajax日历扩展器控件,我需要计算未来的日期..我:-an用户的有效期。如果我选择在我的文本中的日期1它将是2012年7月12日,在我的text2中它应该计算接下来的30天,并将其显示为2013年7月1日...请找我任何解决方案...
Hi,
I have an ajax calendar extender control where i need to calculate the future date..ie:-an Expiry date for users.If i select to days date in my text 1 it will be 7/12/2012 and in my text2 it should calculate for next 30 days and display it as 7/1/2013...Pls find me any soln...
推荐答案
试试这个
Try this
DateTime firsttext= Convert.ToDateTime("7/12/2012");
// add digit in textbox or add some validation
DateTime answer = firsttext.AddDays(Convert.Todouble(TextBox2.Text));
参考这个
将营业日添加到日期
http://msdn.microsoft.com
或
如果你想通过javascript完成,那么在第二个文本框中调用此函数onchange事件
Refer this
Adding Business Days to a Date
http://msdn.microsoft.com
or
If you want it done through javascript then call this function in second textbox onchange event
function aaddate()
{
var txt1 = document.getelementByID('<%# txt1.ClientID%');
var txt2 = document.getelementByID('<%# txt2.ClientID%');
var today = new Date(txt1.value);
var tomorrow = new Date();
tomorrow.setDate(today.getDate()+ parseInt(txt2.value));
}
string txt1 = "7/12/2012";
DateTime dt = Convert.ToDateTime(txt1);
DateTime dt1 = dt.AddDays(30);
string txt2 = dt1.ToString("dd/MM/yyyy");
--SJ
--SJ
这篇关于如何计算Asp.Net中的未来日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!