Page 1 of 1

Date Ranges

Posted: Mon Jul 17, 2006 7:22 am
by b00ker_b0y
Hi people;

Does anybody have an idea how to tackle this problem.

I will have a date range i.e. 17/07/2006 - 10/08/2006.

What I would like to be able to do it work out many days are in July from that range and how many are in August.

Anybody have any idea?

Thanks.

Posted: Mon Jul 17, 2006 7:30 am
by feyd
  1. Break the two dates apart into their components.
  2. use range() to create an array of the months to calculate on
  3. looping over the array from range(), use date() to pull how many days are in that month
  4. for the first month, subtract the day number from the components.
  5. for the last month, replace the number of days in the month with the day number from the components.

Posted: Mon Jul 17, 2006 7:42 am
by b00ker_b0y
thank you; i will give that ago.

What do you mean my conponents tho?!

(new to all this)

Thanks again.

Posted: Mon Jul 17, 2006 7:45 am
by feyd
day, month and year.