To get the previous Month

C# Code :


DateTime LastMonthDate=DateTime.Now.AddMonths(-1);
Response.Write(LastMonthDate.ToString("MM/dd/yyyy"));

VB.net Code:

DateTime.Now.AddMonths(-1).ToString("MM/dd/yyyy")

Result
if the current date is 10/22/2008 , then the output of the above code is 09/22/2008


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: