In Django, i have a model that look like this:
class Foo(models.Model):
...
created = models.DateTimeField(default=None)
...
And I try to query like:
q = Foo.objects.values('created').distinct()
So far everything is great.
The problem is, if I have records created by a few seconds or milliseconds apart, I want to count them as one record.
So only queries created over a minute apart will be retrieved as two separate queries. How to do it? Thanks.
EDIT: Trunc is a nice option, but didn't answer the question exactly.
Here's an example: If there are two records in DB, In the first record, the value in the created field is:
2020-02-23 12: 19: 59.000000
And in the second:
2020-02-23 12: 20: 01.000000
Trunc will retrieve two records, since they are two separate minutes.
but I want to retrieve only one record, because the time difference between the two records is less than a minute ..