Calculating the end of the month

  • Thread starter Thread starter mastermind
  • Start date Start date
M

mastermind

I have a sheet that needs to be able to alternate between the 15th and
last day of each month. The user will enter a start date, and I need
the code to start at this point and jump to the next date. Example:


Start date: 01/15/06
run code
date: 01/31/06
run code
date: 02/15/06
run code
date: 02/28/06

and so on. Can anyone help me with this problem? Thank you.
 
Hi mastermind,

The first of next month can be determined by getting the "0" day for the
next month. Here's a function that should work for you. Just pass in the
current date, and it will return the next date:

Public Function gdtGetNextPeriodEnd(rdtCurrentPeriodEnd _
As Date) As Date
If Day(rdtCurrentPeriodEnd) = 15 Then
gdtGetNextPeriodEnd = DateSerial(Year( _
rdtCurrentPeriodEnd), Month(rdtCurrentPeriodEnd) _
+ 1, 0)
Else
gdtGetNextPeriodEnd = DateSerial(Year( _
rdtCurrentPeriodEnd), Month(rdtCurrentPeriodEnd) _
+ 1, 15)
End If
End Function

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]
 

Ask a Question

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.

Ask a Question

Back
Top