如何计算Asp.Net中的未来日期 [英] How to calculate the Future Date in Asp.Net

查看:71
本文介绍了如何计算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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆