Quantcast
Channel: My name is Justin Kohnen, and I’m a Geek.
Viewing all articles
Browse latest Browse all 28

Computing First and Last Day of the Month

$
0
0

I stumbled across this the other day and I thought it was so slick I would share.

This example computes the DateTime for both the first and last day of the current month.

var monthStartDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
var monthEndDate = start.AddMonths(1).AddDays(-1);

You can take the range even further by changing the “AddMonths” number.

Pretty slick.


Viewing all articles
Browse latest Browse all 28

Trending Articles