Functions to get First Date and Last Date of Previous Month and Year.
private DateTime LastDateOfPreviousMonth()
{
return DateAndTime.DateAdd("d", -1, DateTime.Now.Month.ToString() + "/01/" + DateTime.Now.Year.ToString());
}
Note:
In C#, you will need to add the namespace as 'using Microsoft.VisualBasic' in the source code unit. Also Add Reference to 'Microsoft.VisualBasic' dll.
private DateTime FirstDateOfPreviousMonth()
{
int Yr, Mnth;
DateTime prev = DateTime.Now.AddMonths(-1);
Yr = prev.Year;
Mnth = prev.Month;
return Convert.ToDateTime(Mnth.ToString() + "/01/" + Yr.ToString());
}
First Date and Last Date of Previous Month and Year C#
Posted by Techie Cocktail | 5:40 PM | C-Sharp | 0 comments »
Subscribe to:
Post Comments (Atom)
0 comments
Post a Comment