Breaking down a term to periods

  • Thread starter Thread starter SW
  • Start date Start date
S

SW

Hello,

I need to write code to break down i.e. 5 years term into monthly periods.
For example, a Jan 1,2006 to Dec 31,2010 term, I need to break down this
term to Jan 1,2006-Jan 31, 2006; Feb 1, 2006-Feb 29, 2006; Mar 1,2006-Mar
31,2006.......Nov 1, 2010-Nov30, 2010; Dec 1, 2010-Dec 31, 2010.
** will also need to take leap year into consideration

Thanks!!
 
You did not say what you planned to do with this breakdown or how you want it
presented, but here are a couple of things that will help.
If you start with the first period in your example, 1/1/2006, you can get
the next month with:
PriorPeriod = #1/1/2006#
NextPeriod = DateAdd("m", 1, PriorPeriod)
To get the first day of the month:
FirstDay = DateSerial(Year(NextPeriod), Month(NextPeriod), 1)
To get the last day of the month (leap year included):
LastDay = DateSerial(Year(NextPeriod), Month(NextPeriod) + 1, 0)

Hopefully, that will give you a good start.
 

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