Here's a simple example (done in the immediate window):
? cDate("3/1/2004") - 1
2/29/2004
cDate() converts the text to a date. In this case, if you want to know what
the last day of the month for February is, then set it for the first day of
the following month and then back up 1 day.
Public Function EOMonth(dtDate As Variant) As Variant
If Not IsNull(dtDate) Then
EOMonth = DateSerial(Year(dtDate), Month(dtDate) + 1, 0)
End If
End Sub
Public Function EOMonth(dtDate As Variant) As Variant
If Not IsNull(dtDate) Then
EOMonth = DateSerial(Year(dtDate), Month(dtDate) + 1, 0)
End If
End Sub
Returns the serial number date for the last day of the month that is the
indicated number of months before or after start_date. Use EOMONTH to
calculate maturity dates or due dates that fall on the last day of the
month.
Syntax
EOMONTH(start_date,months)
Start_date is a date that represents the start date.
Months is the number of months before or after start_date. A positive
value for months yields a future date; a negative value yields a past date.
However, this question was multiposted, and I'm sure I answered it correctly
in one of the (many) other newsgroups to which it was posted.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.