Finding Days in Month

by Sep 16, 2010

If you need to determine the days in a given month, you can use the static DaysInMonth() function provided by the DateTime type. As you can see, the days in a month are not always the same for every year:

[DateTime]::DaysInMonth(2009, 2)
28
[DateTime]::DaysInMonth(2008, 2)
29

Twitter This Tip! ReTweet this Tip!