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