Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Django: Group by date (day, month, year)

from django.db.models.functions import ExtractMonth
Sales.objects
    .annotate(month=ExtractMonth('timestamp')) 
    .values('month')                          
    .annotate(count=Count('id'))                  
    .values('month', 'count')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Group #date
ADD COMMENT
Topic
Name
8+7 =