Click here to Skip to main content
15,888,072 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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]
Posted
Updated 26-Dec-11 0:30am
v2
Comments
mayankshrivastava 26-Dec-11 9:12am    
sir, i want all start to end date's except friday.. what kind of code i have to write ?
please reply

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

Find the count of a weekday between two dates without iterating/looping[^]
 
Share this answer
 
Try:
C#
DateTime dt = DateTime.Now;
dt = dt.AddDays(17);
Console.WriteLine(dt.ToString());
 
Share this answer
 
Comments
mayankshrivastava 26-Dec-11 6:58am    
thanx for reply...

it works but when i select another date it takes only today's date???
OriginalGriff 26-Dec-11 7:07am    
Replace the DateTime.Now with another date...
mayankshrivastava 26-Dec-11 7:14am    
how ?

i am using calander contorl.
OriginalGriff 26-Dec-11 8:10am    
Have you tried Calendar.SelectedDate?
mayankshrivastava 26-Dec-11 8:25am    
ya thanks a lot i got it....
please solve my another query
my text box is not working..
dt = dt.AddDays("?");
i have to pass text box value..
how i pass ?
it takes bool value.

please reply
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.

C#
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. :)
 
Share this answer
 
Comments
mayankshrivastava 26-Dec-11 8:34am    
my text box is not working.. dt = dt.AddDays("?"); i have to pass text box value.. how i pass ? it takes bool value. please reply
DateTime.Now.AddDays([number that you have entered in the textbox])


Thanks
 
Share this answer
 
Comments
mayankshrivastava 26-Dec-11 8:34am    
my text box is not working.. dt = dt.AddDays("?"); i have to pass text box value.. how i pass ? it takes bool value. please reply
my text box is not working.. dt = dt.AddDays("?"); i have to pass text box value.. how i pass ? it takes bool value. please reply

Answer:
dt = dt.AddDays(toInt32(textbox1.Text));
 
Share this answer
 
Comments
mayankshrivastava 26-Dec-11 9:09am    
sir,
i want all start to end date's except friday..
what kind of code i have to write ?

please reply
Rajesh Anuhya 26-Dec-11 9:11am    
i am not getting exactly, what you are asking , can you elaborate it more.
mayankshrivastava 26-Dec-11 9:21am    
suppose i select a start date today its 26th dec and in text box i put 15 than the answer is 10th Jan but i want only 6 days in a week(except Friday) that's means i want ans is 12th Jan because there are two Fridays in between 26th to next 15 days(30th DEC and 6th Jan).
Rajesh Anuhya 26-Dec-11 9:25am    
See my Second Answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900