﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18969	"ORM filtering with ""year"" lookup for dates"	saippuakauppias	nobody	"When I do query with lookup in orm:

{{{
Document.objects.filter(given_on__year=1).values_list('given_on', flat=True)
}}}
or
{{{
Document.objects.filter(given_on__year='0001').values_list('given_on', flat=True)
}}}

I get results:
{{{
[datetime.date(2012, 8, 31), datetime.date(2012, 8, 31), datetime.date(2012, 8, 29), '...(remaining elements truncated)...']
}}}

But I would expect dates in interval 0001-01-01 ... 0001-12-31 (YYYY-MM-DD).

Generated SQL query:
{{{
print Document.objects.filter(given_on__year='0001').values_list('given_on').query
}}}


{{{
SELECT ""documents_document"".""given_on"" 
FROM ""documents_document"" 
WHERE ""documents_document"".""given_on"" BETWEEN 1-01-01 00:00:00 and 1-12-31 23:59:59.999999 
ORDER BY ""documents_document"".""created_on"" DESC
}}}

In django not possible give results with first year.

PS: question in [http://stackoverflow.com/questions/12425853/postgresql-between-with-datetime stackoverflow]
PPS: tested in Django 1.3.2 version"	Bug	closed	Database layer (models, ORM)	dev	Normal	duplicate		Türker Sezer tomas.ehrlich@…	Accepted	1	0	0	0	0	0
