[Tutor] return all the days between two dates using the calendar module

Norman Khine norman at khine.net
Mon Aug 22 19:46:17 CEST 2011


ok ignore, this works

def date_range(start_date, end_date):
    r = (end_date+datetime.timedelta(days=1)-start_date).days
    return [start_date+datetime.timedelta(days=i) for i in range(r)]



On Mon, Aug 22, 2011 at 5:27 PM, Norman Khine <norman at khine.net> wrote:
> Hello,
> I have this code http://pastie.org/2411735 which basically reads a CSV
> file, takes the date field and then for each day executes an SQL query
> to pull the amount of orders that have been generated.
>
> My issue I have is that on the back-office of the e-commerce package
> the total orders for the same range of time returns different amount,
> even though the SQL is correct.
>
> One possible error may occur from the fact that I am using the CSV
> file for the date range, rather than the calendar module, and I am
> unsure how to return the list of dates for a given range. So in line
> 72, rather then using the dates in the CSV file I would like to build
> this list from the calendar module.
>
> I got this, http://pastie.org/2411864 but this just adds a day and is
> not 100% precise.
>
> Any advice much appreciated.
>
> Norman
>
> --
> ˙ʇı ɹoɟ ƃuıʎɐd ǝɹ,noʎ ʍou puɐ ǝɔıoɥɔ ɐ ʞooʇ ı ʇɐɥʇ sı 'ʇlnɔıɟɟıp sı ʇɐɥʍ
> ˙uʍop ǝpısdn p,uɹnʇ pןɹoʍ ǝɥʇ ǝǝs noʎ 'ʇuǝɯɐן sǝɯıʇ ǝɥʇ puɐ 'ʇuǝʇuoɔ
> ǝq s,ʇǝן ʇǝʎ
> %>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or
> chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )
>



-- 
˙ʇı ɹoɟ ƃuıʎɐd ǝɹ,noʎ ʍou puɐ ǝɔıoɥɔ ɐ ʞooʇ ı ʇɐɥʇ sı 'ʇlnɔıɟɟıp sı ʇɐɥʍ
˙uʍop ǝpısdn p,uɹnʇ pןɹoʍ ǝɥʇ ǝǝs noʎ 'ʇuǝɯɐן sǝɯıʇ ǝɥʇ puɐ 'ʇuǝʇuoɔ
ǝq s,ʇǝן ʇǝʎ
%>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or
chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )


More information about the Tutor mailing list