﻿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
24793	Subtracting DateTime fields in a query expression should use timediff	Ben Buchwald	Simon Charette	"If I have a model with start and end DateTime fields, I'd like to be able to annotate a query with the duration. For instance, with the model
{{{
class Event(Model):
    start_time = DateTimeField()
    end_time = DateTimeField()
}}}

I want to be able to do the following query: {{{Event.objects.annotate(duration=ExpressionWrapper(F('end_time')-F('start_time'),output_field=DurationField()))}}}. However this yields and incorrect result. At least in MySQL, the proper SQL is {{{timediff(end_time,start_time) as duration}}}. I have not found an alternate way to do this with Django's ORM without writing SQL."	New feature	closed	Database layer (models, ORM)	dev	Normal	fixed	datetime duration expression	josh.smeaton@… Simon Charette	Ready for checkin	1	0	0	0	0	0
