JUN
2011
2011
17
Posted under:
Tutorial
C# has a DateTime structure to hold date and time value in a single variable. The following script will gives you first and last date of given months in two lines of C# code. Assuming that the first and last dates we're looking for is for current month (now), the code would be like this:
DateTime FirstDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);DateTime LastDate = FirstDate.AddMonths(1).AddDays(-1);
601 Hits