Is it posible to compare a variable to two accumalated database fields in a django query?
NickName:cyrion1000 Ask DateTime:2015-08-26T02:19:43

Is it posible to compare a variable to two accumalated database fields in a django query?

I am trying to filter the results of a django query according to a given end and start time. In my model I have a start time and duration for every database entry. I give the function the parameters endTime and startTime

What I would like is to have a filter that checks if the given endTime is smaller than the start time + duration given in the database row, so something like the following query:

query = Results.objects.filter(
            r_timeStart__gte=startTime,
            (F('r_timeStart') + F('r_duration'))__lte=endTime)

This obviously does not work. Now is my question: is it possible to compare a variable to two accumalated database fields in a django query?

Copyright Notice:Content Author:「cyrion1000」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/32211294/is-it-posible-to-compare-a-variable-to-two-accumalated-database-fields-in-a-djan

More about “Is it posible to compare a variable to two accumalated database fields in a django query?” related questions

Is it posible to compare a variable to two accumalated database fields in a django query?

I am trying to filter the results of a django query according to a given end and start time. In my model I have a start time and duration for every database entry. I give the function the parameters

Show Detail

Is it posible in Django to authenticate a user with 2 fields?

I'm developing (currently designing) a Django app for managing students in an institute. The custom users in my app have a file number as username field. But, the app is intendeed to handle more th...

Show Detail

Comparing two fields in django

can any body suggest me any idea about how can i compare two fields in django. as i have two password fields in my forms.py file. now i want to compare the two fields and if both are same then save...

Show Detail

Extbase query to compare two fields in same table

Is it possible to compare two database fields in the query api? For example I want compare the fields tstamp and crdate like: SELECT * FROM tt_content WHERE tstamp > crdate; In the query api I...

Show Detail

Compare two database fields in extbase repository

I am using TYPO3 8. In my extension I have a database table "company" in which I store for each company the total number of places (number_places) and the number of occupied places (occupied_places...

Show Detail

TFS 2010 Query - Compare two fields

Using TFS 2010. Creating a new query and in the filters added a comparison between two similar type fields i.e. Estimated Work < Remaining Work. Estimated Work is my custom int field while Rema...

Show Detail

Django - Compare Model Code to Database

I maintain a Django project with a database that has several model constraints that have fallen out of sync with the actual database. So, for example, some model fields have null=False set, but the

Show Detail

Compare two fields in Waterline/Sails.js query

I want to compare two fields in my Waterline query in Sails.js application, e.g.: SELECT * FROM entity E WHERE E.current < E.max. I've tried the following code, but it's expecting integer value...

Show Detail

Mysql Compare Two Database Tables and Fields

I have to compare two database tables and fields ( Not their DATA) . Say Live DB and Development DB. In live DB there are 200 tables and in development DB there are 218 Tables With some new column ...

Show Detail

Compare two Django fields to be identical, raise Validation error if not

I am putting together a Non Disclosure Form(NDA) on my clients site and need to add some field comparison validation. When someone wants more information on one of my clients listings, they would

Show Detail