How get Yesterdays date in ASP.Net

Use DateTime.AddDays() method  to get future date or previous date if you need number of days difference from current date

  DateTime d = DateTime.Today.AddDays(-1);
  string startdate = d.ToString("MM/dd/yyyy");

Output will be : {12/25/2012 12:00:00 AM}

How can I get a date after 10 days  in asp.net

DateTime d  = Date.Now.AddDays(10);

string startdate = d.ToString("MM/dd/yyyy");
Output will be : {12/30/2012 12:00:00 AM}

Related Alrticles

FREE!!! Registration