[Tutor] set the BETWEEN range in the SQL query using the python datetime function

Peter Otten __peter__ at web.de
Fri Jun 24 12:18:19 CEST 2011


Norman Khine wrote:

> hello, i have this code http://pastie.org/2112997
> 
> but i am not sure how to make the date range so that i get a list
> based on the daily totals not the results i am now getting:
> 
> (2L, Decimal('173.958344'), Decimal('159.966349')) 2011-06-23 00:00:00
> 2011-06-23 23:59:59
> (2L, Decimal('173.958344'), Decimal('159.966349')) 2011-06-22 00:00:00
> 2011-06-23 23:59:59

What should the result look like? Can you give a simplified example with 
input and output data?

> the problem is that i am unsure how best to set the BETWEEN range in
> the SQL query using the python datetime function.

My guess is that you can move more of the problem from Python into SQL if 
you add a GROUP BY clause.




More information about the Tutor mailing list