Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine the last day of a month 3

Status
Not open for further replies.

rbowes

Technical User
Mar 7, 2000
150
US
I need to create a function that determines the last day of the month - determined by user. Does anyone have a quick few lines of code for a function.

Thanks

Bob
 
Yeah, one line...

DateSerial(<year>, <month> + 1 , 0)

Example:

Dateserial(&quot;1999&quot;, &quot;4&quot;, 0) = 3/31/1999

Dateseral function is pretty cool like that! When you place a &quot;0&quot; in the function, it always returns the last date of the previous month. To parse out the date itself, simply use the Month, Day, or Year function.

Gary
gwinn7
 
This should do it for you Bob.

Function FindEOM (MyDate)

Dim NextMonth, EndOfMonth
NextMonth = DateAdd(&quot;m&quot;, 1, MyDate)
EndOfMonth = NextMonth - DatePart(&quot;d&quot;, NextMonth)
FindEOM = EndOfMonth

End Function

HTH

Steve :)
 
Thanks. I have been so busy with other things that when this fell into my lap, I decided that I thought maybe that someone could save me some time. And both of you did!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top