# Thread: Get last day of month ??

1. Registered User
Join Date
Oct 2003
Posts
311

## Unanswered: Get last day of month ??

vb.net has something like

month.lastday()

i need to set a txtbox.value to the last day of the month,

i can get the month :

cstr(cint(month(now()))-1)

is there a function or simple way to return 9/30/03 if i run the code today?

2. Registered User
Join Date
Oct 2003
Location
Posts
574
get the first day of the next month and subtract 1 day:

3. Registered User
Join Date
Oct 2003
Location
Ger
Posts
1,969
U can use next function to compute the days in a month, then add them to the beginning of your month -1

Function DaysOfMonth(anyMonth As Byte) As Integer
Dim anyDate As Date
Dim nDays As Integer

anyDate = DateSerial(Year(Date), anyMonth, 1)

' Adding one month to the given date then calculate the Difference
between the two dates
nDays = DateSerial(Year(anyDate), Month(anyDate) + 1, Day
(anyDate)) _
- DateSerial(Year(anyDate), Month(anyDate), Day(anyDate))
DaysOfMonth = nDays
End Function

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•