﻿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
22528	Filter by month not working	ivancho1707@…	nobody	"Hello

I recently migrated from 1.4.2 to 1.6.3 and since then a some queries are not returning results. I debugged those and find that it happens whenever I try to filter an entity by month.

{{{
transactions = Transaction.objects.filter(created_date__month=some_date.month) 
print transactions.count()
}}}


this returns 0 results always. 

Using Django Toolbar I found what kind of query was executing behind and it was something like the following (BTW I am using mysql as db engine and I already set Time Zone Tables.)

{{{
SELECT ... FROM `app_transaction` WHERE EXTRACT(MONTH FROM CONVERT_TZ(`app_transaction`.`created_date`, 'UTC', 'America/Mexico_City')) = 6)
}}}

which differs from docs for this version:

{{{
SELECT ... WHERE EXTRACT('month' FROM pub_date) = '12';
}}}

well I'm not really fond to databases but it looks like it's converting to my local timezone before getting all transactions that were made in June of any year, it looks like it must work to me. 

In 1.4.2 did it exactly like the example, so I assume there's something weird in the query and needs to be fixed

{{{
SELECT ... FROM `app_transaction` WHERE EXTRACT(MONTH FROM `app_transaction`.`created_date`) = 6)
}}}

Cheers"	Bug	closed	Uncategorized	1.6	Normal	needsinfo			Unreviewed	0	0	0	0	0	0
