I am using the following SQL code to check previous sunday:
DATE_ADD(tbl.date, INTERVAL (- 1) * DAYOFWEEK(tbl.date) + 1 DAY) AS week
Could you tell me whether I can use the same thanks to django models ?
I have completely no idea how to do this.
In another words I want to group by sunday in my query
My model:
class tbl_data( models.Model ):
date = models.DateField(verbose_name="Date")
identifier = models.CharField(max_length=10, verbose_name="Identifier")
value = models.FloatField(verbose_name="Value")
def __unicode__(self):
return str( self.date ) + '-' + str( self.identifier )
data is uploading everyday, I want to group it by week ( Sunday is my first day )
Thanks in advance,