Link to home
Start Free TrialLog in
Avatar of dmontgom
dmontgom

asked on

Finding the last months start date given intial date in Python

Hi,

Lets say my activation date is 1/8/2008 and will use this as the base date or billing date.

Given todays date, I need to find the last billing date.  So..if todays date is 10/20/09 the start of the current cycle is 10/8/09.  How do I find the current billing cycle taking into account year and month?  E.g. if the current date is 1/2/2009 I need to know that 12/08/2008 was the start of the last billing cycle.

Please show code.

Thanks
Avatar of HonorGod
HonorGod
Flag of United States of America image

What is the algorithm / recipe for determining the start of a billing cycle?
Avatar of dmontgom
dmontgom

ASKER

Take it as given. For different clients, the start date can be any month or any day.
So, when you say that you want to "find the last billing date", given an input date of 10/20/2009 and a billing day of 8 (e.g, say you started your billing cycle on 1/8/2000), you want it to return 10/08/09, right?
ASKER CERTIFIED SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How you want one-month-ago(31.mar.2006) or one-month-ago(28.feb.2006) to work?
Ie. when base date's day doesn't exist in the previous month?
Thanks
Thanks for the grade & points.

Good luck & have a great day.