﻿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
29767	Failed to cast between datetime and date on SQLite	Rémy Hubscher	nobody	"While using with Annotations and Cast I realized that the casting between datetime and date with SQLite3 was kinda broken.


{{{
Cast(""datetime_field"", DateField())
}}}
 is transformed into 
{{{
CAST(""datetime_field"" AS TEXT)
}}}
 rather than for instance 
{{{
substr(CAST(datetime_field AS TEXT),0,11)
}}}

I was able to use extra to fix that and run the query. However I would like to fix this.

This is especially useful for my usecase where I want to GROUP BY the annotated value.

I wrote a test for it https://github.com/django/django/pull/10387/files"	Bug	closed	Database layer (models, ORM)	2.1	Normal	fixed	sqlite		Ready for checkin	1	0	0	0	0	0
