Return to Snippet

Revision: 17175
at August 26, 2009 07:16 by pats


Initial Code
def quarters_range(date_to, date_from=None):
    result = []
    if date_from is None:
        date_from = datetime.now()
    quarter_to = (date_to.month/4)+1
    for year in range(date_from.year, date_to.year+1):
        for quarter in range(1, 5):
            if date_from.year == year and quarter <= quarter_to:
                continue
            if date_to.year == year and quarter > quarter_to:
                break
            result.append([quarter, year])
    return result

Initial URL

                                

Initial Description

                                

Initial Title
calculate quarters range between specific dates

Initial Tags
date

Initial Language
Python