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

DatePart: End of the Month

Status
Not open for further replies.

BradB

MIS
Jun 21, 2001
237
US
ActDate = beginning of the current month Ex. 4/1/2002

The code below gives me the end of the previous month. I want the end of the CURRENT month.

lstEndDate.AddItem (actDate.Value - DatePart("d", actDate))

Eventually, I'll have to have four months from beginning to end. I just can't get the end of the month to work.
ListBox1 ListBox2
4/1/2002 to 4/30/2002
5/1/2002 to 5/31/2002
6/1/2002 to 6/30/2002
7/1/2002 to 7/31/2002
 
Hi BradB,

Try the following:

lstEndDate.AddItem(actDate.Value + DateAdd("m", 1, actDate) - DatePart("d", actDate)

It adds one month to the date then subtracts a day.

Good Luck. mikey2nicey

Dream, but don't quit your day job.
 
Hi again BradB,

There should of course be an extra bracket on the end. Oops!

Regards. mikey2nicey

Dream, but don't quit your day job.
 
EndOfMnth = DateSerial(Year(Date), Month(Date) + 1, 0)
MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top