Loading ...

Find Date after a given week(s) or month(s) | CodeAsp.Net

Find Date after a given week(s) or month(s)

4.82 
 /5
4.82 (1votes)

Here I am discussing to find date after a given week or months.
For example I want to find the date after 1 week or 2 months from today.
Find date after 2 week or 2 months then we can achieved this as like:

DateTime dateTime = DateTime.Now.AddDays(14);
//we can also do this as DateTime.Now.AddDays(2*7)

DateTime dateTime1 = DateTime.Now.AddMonths(2);



The output will be:

11/18/2009 3:59:43 PM
1/4/2010 3:59:43 PM


If we want only date part then we can achieved this as like:

string dt = DateTime.Now.AddDays(2*7).ToShortDateString();

string dt1 = DateTime.Now.AddMonths(2).ToShortDateString();


The output will be:

11/18/2009
1/4/2010




Comments (1)

   
rdx
rdx
it is not a good answer
4/27/2011
 · 
by
  • :*
  • :*
  • :
 *

Top Posts