|
-
Feb 10th, 2011, 11:37 AM
#1
Thread Starter
Addicted Member
How to last day of last month??
I am trying to get last day of last month (say today is 02/11/2011 and I need 01/31/2011).
How can I do that in C#
The following code will get last day of any month that user types into TextBoxPeriod.Text. Based on the system date, I need to get last day of last month.
DateTime aSelectedDate = Convert.ToDateTime(TextBoxPeriod.Text);
DateTime datlastDayOfThisMonth = new DateTime(aSelectedDate.Year, aSelectedDate.Month, 1).AddMonths(1).AddDays(-1);
lastDayOfThisMonth = Convert.ToString(datlastDayOfThisMonth);
lastDayOfThisMonth = lastDayOfThisMonth.Substring(0, 10);
Thanks
nath
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|