X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6A9163A46B4 for ; Thu, 18 Nov 2004 21:15:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39676-10 for ; Thu, 18 Nov 2004 21:15:34 +0000 (GMT) Received: from window.monsterlabs.com (window.monsterlabs.com [216.183.105.176]) by svr1.postgresql.org (Postfix) with SMTP id ABE463A3BA6 for ; Thu, 18 Nov 2004 21:15:34 +0000 (GMT) Received: (qmail 21434 invoked from network); 18 Nov 2004 21:15:34 -0000 Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.22?) (64.3.242.80) by 0 with SMTP; 18 Nov 2004 21:15:34 -0000 In-Reply-To: <419D0DC6.5080504@candoltd.com> References: <419D0DC6.5080504@candoltd.com> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: pgsql-sql@postgresql.org From: Thomas F.O'Connell Subject: Re: Comparing Dates Date: Thu, 18 Nov 2004 15:15:30 -0600 To: Nick Peters X-Mailer: Apple Mail (2.619) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/182 X-Sequence-Number: 19501 Nick, You need to quote your date constant value: '2004-06-08' select '2004-06-08'::date > 2004-06-08; ?column? ---------- t (1 row) select 2004-06-08; ?column? ---------- 1990 I'm not exactly sure how the bare string is converted internally, but it's clearly not a complete date like you're expecting. -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260-0005 On Nov 18, 2004, at 3:01 PM, Nick Peters wrote: > Hey, > > I am trying to compare dates in a sql statement. this is what i have > tried: > > SELECT * FROM transactions WHERE shippingdate>2004-06-08 AND > transtype='Sale'; > > but it returns all rows. When i switch the > with a < it returns > nothing. I have even tried with todays date and have got the same > results. So i guess my question is how do i compare two dates? BTW the > column by the name of shippingdate is a date data type with the same > format as the dates show above. > > Thanks in advance. > > -Nick > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to > majordomo@postgresql.org