There are a number of different calendars (depending what region of the
world you are talking about, and what era). Each calendar implements a
GetDaysInMonth method.
To use the current region's calendar, use:
Imports System.Globalization
..
..
..
CultureInfo.CurrentCulture.Calendar.GetDaysInMonth (year, month)
To get the current month's last day, use:
Function EndOfMonth() As Integer
Dim d As Date = Date.Today();
Return CultureInfo.CurrentCulture.Calendar.GetDaysInMonth (d.Year,
d.Month)
End Function
The DateTime type (Date type in VB) has a similar method called DaysInMonth,
but it doesn't respect different regional calendars. It hardcodes a 365 day
year, but checks for leapyear. If you are writing an app capable of being
used internationally, it's best to use the regional calendar instead.
-Rob Teixeira [MVP]
<coleenholley> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
Thank you very much! I will try this. I'm looking at DatePart,
DateSerial, DateAdd functions. The problem is that none of them allow you
to take today() and get the end of month value using a simple function.
Then you have to take into account leap year for February when writing a
function to find the last day of each month with 31 days and each month with
30 days. It's was much simpler in Access - why oh why - didn't Microsoft
incorporate this functionality into VB.Net? It was SO useful! Thanks
Again. Coleen
---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest
Community Website:
http://www.dotnetjunkies.com/newsgroups/