Hello Everyone, 

This is my first posting on this forum, please let me know if I have done 
anything incorrectly.  

I have a seemingly simple task I am trying to achieve with one of my 
projects.  Looking to see if the following is possible, and if so what the 
syntax would be with the Django ORM.  Apologies in advance if this is a 
trivial one. 

I have a requests model that has a bunch of time stamps(6 to be specific) 
and these timestamps record milestones in the request, set throughout the 
lifecycle of a request.  Im trying to write a query that gets a set of 
records, calculates the difference between two timestamps and averages 
those differences over the queryset.  For example, i want to get the 
average amount of time between the created_at timestamp and an approved_at 
timestamp over a set of records.  

I seem to be able to do this in postgres with the following, how can I do 
this with the Django ORM? 

select avg(approved_at - created_at) as approval_time from 
dashboard_labrequest;

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/da6f1f06-e036-46ce-9405-520004de18afn%40googlegroups.com.

Reply via email to