Showing posts with label DateTime. Show all posts
Showing posts with label DateTime. Show all posts

Monday, October 13, 2008

How to get last day of the last month with asp.net

///


/// Returns the last date of the previous month in yyyy-MMM-dd format...
///
/// Date to get the last date of its previous month

///

public string GetLastDate(DateTime dt_now)
{
string str_Last = "";
DateTime dt_Last = new DateTime();
int _Day = 0;
_Day = dt_now.Day;
TimeSpan ts = new TimeSpan(_Day, 0, 0, 0, 0);
dt_Last =
dt_now.Subtract(ts);
str_Last = dt_Last.ToString("yyyy-MMM-dd");
return
str_Last;
}



-
ShriKrishna Bhardwaj , With ASP.Net, SQL Server, Javascript