Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 4102 invoked from network); 16 Nov 2004 05:47:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 16 Nov 2004 05:47:57 -0000 Received: (qmail 58229 invoked by uid 500); 16 Nov 2004 05:47:51 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 58209 invoked by uid 500); 16 Nov 2004 05:47:51 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Users List" Reply-To: "Apache Torque Users List" Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 58196 invoked by uid 99); 16 Nov 2004 05:47:51 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=DNS_FROM_RFC_ABUSE X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [216.136.130.249] (HELO web10807.mail.yahoo.com) (216.136.130.249) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 15 Nov 2004 21:47:48 -0800 Received: (qmail 36763 invoked by uid 60001); 16 Nov 2004 05:47:45 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=Wi4xiPc3/ISBJyAYtsedHjQ19bnJzBEi7khLqBBhdKacucgRHqgsQn2XLIuC9PUxoI36+uDB56WcnOJbOpx2j678LQ7Q1Me4naJ9d1Le4P2W2P5P1eEq/7bExq1umyDSitlJ9GTsulrOXySgakhHyZsIXvZOBTnHge6GQXGJLZI= ; Message-ID: <20041116054745.36761.qmail@web10807.mail.yahoo.com> Received: from [201.137.86.114] by web10807.mail.yahoo.com via HTTP; Mon, 15 Nov 2004 21:47:45 PST Date: Mon, 15 Nov 2004 21:47:45 -0800 (PST) From: Ruy Diaz Jara Subject: Re: Subtracting fields in the Where Clause To: Apache Torque Users List In-Reply-To: <20041116053338.51863.qmail@web10804.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N In trying to simplify the query in order not to confuse the community, I overdid it, because it would appear that the solution would be a simple: Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 5); cr.add(SubscribersPeer.END_OF_SUBSCRIPTION_DATE, cal.getTime()); However, the problem I am facing is because in reality I am not comparing to a constant (5) but rather to a field from another table. The actual query is: SELECT user_id FROM details d, subscribers s WHERE s.app_id = d.app_id AND TO_DAYS(s.end_of_subscription_date) - TO_DAYS(SYSDATE()) = d.end_warning Given that the number of days until expiration varies from application to application, I want to get this as a dynamic value. I know a solution would be to do several queries (one for each application), but with a query such as the one presented above, I could do all of it in a single step. So executeQuery could also do the trick, but I would like to avoid it in order to obtain DB independence. Thanks for any help. Ruy --- Ruy Diaz Jara wrote: > Hi, > > I'm trying to familiarize myself with Torque and so far I've been having some > trouble porting SQL statements to Criteria. Currently, what I am attempting > to > do is to get the following query (originally MySQL 4.0): > > SELECT user_id > FROM subscribers s > WHERE to_days(s.end_of_subscription_date) - to_days(SYSDATE()) = 5 > > The query extracts a list of users whose subscriptions to a service will end > in > 5 days. How can I add a Criterion with a mathematical expression? Is it > possible or do I have to use BasePeer.executeQuery()? > > Regards > Ruy > > > > __________________________________ > Do you Yahoo!? > Meet the all-new My Yahoo! - Try it today! > http://my.yahoo.com > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org > For additional commands, e-mail: torque-user-help@db.apache.org > > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org For additional commands, e-mail: torque-user-help@db.apache.org