datetimes(field_name, kind, order='ASC', tzinfo=None)
Returns a QuerySet that evaluates to a list of datetime.datetime objects representing all available dates of a particular kind within the contents of the QuerySet.
field_name should be the name of a DateTimeField of your model.
kind should be either "year", "month", "day", "hour", "minute" or "second". Each datetime.datetime object in the result list is “truncated” to the given type.
order, which defaults to 'ASC', should be either 'ASC' or 'DESC'. This specifies how to order the results.
tzinfo defines the time zone to which datetimes are converted prior to truncation. Indeed, a given datetime has different representations depending on the time zone in use. This parameter must be a datetime.tzinfo object. If it’s None, Django uses the current time zone. It has no effect when USE_TZ is False.
Note
This function performs time zone conversions directly in the database. As a consequence, your database must be able to interpret the value of tzinfo.tzname(None). This translates into the following requirements:
- SQLite: install pytz — conversions are actually performed in Python.
- PostgreSQL: no requirements (see Time Zones).
- Oracle: no requirements (see Choosing a Time Zone File).
- MySQL: install pytz and load the time zone tables with mysql_tzinfo_to_sql.
Please login to continue.