Created
July 23, 2015 22:05
-
-
Save gregtap/c5ce8b6061c2fd694c76 to your computer and use it in GitHub Desktop.
Postgres Djagno date_trunc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| qs = Foo.objects.filter( | |
| type=0, | |
| duration_minutes__gt=0, | |
| created__gt=thirty_days_ago | |
| ) | |
| qs = qs.extra({ | |
| 'day': "date_trunc('day', foos_foo.created AT TIME ZONE 'America/Chicago')" | |
| }).values('day').order_by().annotate(sum=Sum('duration_minutes')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment