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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Last day of month function 1

Status
Not open for further replies.

blakex1

MIS
Oct 30, 2000
17
US
For those of us that work with dates alot, I wrote a function that might be of help. It takes the current date, and then returns the last day of the current month. For example, if today were August 15th, the function will return August 31. Since the function is based on the system date, it should always return the correct date, as long as your system date on your computer is correct.

Datetest: ((DateAdd("m",1,Date()))-(DatePart("d",((DateAdd("m",1,Date()))-1)))-1)
 
Or:

DateTest: DateSerial(Year(Now), Month(Now) + 1, 0)

(You can Substitute "Date" for "Now") - I didn't because of hte extra characters (2 "e"s?) but it doesn't make any difference in the results.
MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Hay, this is great. I have been looking for something similar to this code. Thanks for your input.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top