# Last Day of the Month

What the Function to find Last Date of the Month ?
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Here are a couple of functions found on the internet:

Public Function FindEOM(ByVal dDate As Date) As String
Dim sNextMonth As Date
Dim sEndOfMonth As Date

sEndOfMonth = sNextMonth - DatePart("d", sNextMonth)
FindEOM = Day(sEndOfMonth) 'Remove the Day() function to
'return the actual date.
End Function

Public Function LastDay(dDate As Date) As Integer
Dim i As Integer
Dim d As Date
For i = 31 To 28 Step -1
If IsDate(Month(dDate) & "/" & Trim(Str(i)) & _
"/" & Year(dDate)) Then
LastDay = i
Exit Function
End If
Next
End Function
0
Commented:
MsgBox Day(DateSerial(Year(Date), Month(Date) + 1, 0))
0
Commented:
try this...

Public Function lastday(sMonth As String) As Date

Dim sDate As String

sDate = "1/" & sMonth & "/" & DatePart("yyyy", Now())
MsgBox lastday
End Function
0
Commented:
Will this work for all regional settings?
0
Commented:
NO....
This will though.

Public Function lastday(sMonth As String) As Date

' sMonth = "Jan","Feb" ...
Dim sDate As String

sDate = sMonth & " 1 " & DatePart("yyyy", Now())

End Function
0
Commented:
Finding the last day of the month

Dim TEMP2 As Date
Dim nLastDay As Integer
TEMP2 = InputBox\$("Please Enter A Date", "LastDay")
nLastDay = DatePart("d", DateAdd("M", 1, TEMP2 - DatePart("d", TEMP2)))
Text1.Text = nLastDay
0
Commented:
Why all the code when vb has the built in function:[ 1 line of code ]
Day(DateSerial(Year(Date), Month(Date) + 1, 0))
In help there are other versions as well

Am I missing something?
0
Author Commented:
Juilette u r correct. Thanks a lot
0
Commented:
OK Thanga..reject julianpointer's proposed answer and accept my comment as an answer...If you have problems doing so, just reject the proposed answer and I will submit my code as an answer.
Thanks
0
Commented: