How to get the Start and End date of Previous month

No.of Views1323
Bookmarked0 times
Downloads 
Votes0
By  Troy   On  15 Feb 2010 23:02:08
Tag : ASP.NET , ASP.NET Controls
How to get the Start and End date of Previous month
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

Here we have to discuss about how to get the Start date and End data of previous Month..

Basically we have calendar control with current month only..

Technologies:

Dot NET 2.0

Language:

C# and VB.NET


Prerequisite

.NET Framework 2.0
Visual Studio 2005

Implementation

C# Code:

DateTime curDate = DateTime.Now;
DateTime startDate = curDate.AddMonths(-1).AddDays(1 - curDate.Day);
DateTime endDate = startDate.AddMonths(1).AddDays(-1);

VB.NET Code

Dim curDate As DateTime = DateTime.Now
Dim startDate As DateTime = curDate.AddMonths(-1).AddDays(1 - curDate.Day)
Dim endDate As DateTime = startDate.AddMonths(1).AddDays(-1)



You can directly pass this code on your button click event check the Result by using Response.Write

Thank you

Venkat

 
Sign Up to vote for this article
 
About Author
 
Troy
Occupation-Not Provided
Company-Not Provided
Member Type-Junior
Location-Not Provided
Joined date-10 Jun 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top