在c#中将指定的天数添加到当前日期 [英] add the specified number of days to current date in c#

查看:231
本文介绍了在c#中将指定的天数添加到当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii Guys ..

请将代码发送给我



添加指定的天数到当前日期



i从日历控件中选择一个日期,然后从文本框中插入一个数字。

所以我只想要一个新的日期添加这个数字



请帮帮我..

紧急



u也给我发了一封邮件

[已删除] @ gmail.com



[edit]切勿在任何论坛发布您的电子邮件地址,除非您真的喜欢垃圾邮件!如果有人回复你,你会收到一封电子邮件让你知道 - OriginalGriff [/ edit]

解决方案

通过下面的提示/技巧,这将给你一个IDEA。



在没有迭代/循环的情况下查找两个日期之间的工作日计数 [ ^ ]


尝试:

 DateTime dt = DateTime.Now; 
dt = dt.AddDays( 17 );
Console.WriteLine(dt.ToString());


从日历中选择日期,然后在选择日期后读取该文本框值。并将文本框值转换为datetime数据类型,然后将日期添加到该日期。



 DateTime _date = Convert.ToDateTime(txtDate。文本); 
_date = _date.AddDays( 4 ); // 尽可能多。





希望这会对你有所帮助。

如果有帮助,不要忘记标记答案。 :)


Hii Guys..
Please send me the code for

add the specified number of days to current date

i choose a date from calender control and than insert a number from text box.
so i just want a new date adding with this number

please help mee..
its urgent

u also send me a mail on
[DELETED]@gmail.com

[edit]Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know - OriginalGriff[/edit]

解决方案

Go through the below Tip/Trick, this will give you an IDEA.

Find the count of a weekday between two dates without iterating/looping[^]


Try:

DateTime dt = DateTime.Now;
dt = dt.AddDays(17);
Console.WriteLine(dt.ToString());


when you select date from calender, then read that textbox value after selecting the date. and convert the textbox value into datetime data type and then add days into that date.

DateTime _date= Convert.ToDateTime(txtDate.Text);
_date =_date.AddDays(4); //as much u want.



Hope this will help you.
Dont forget to mark as answer if it helps. :)


这篇关于在c#中将指定的天数添加到当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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