Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 484061337C2E for ; Tue, 10 May 2011 15:12:58 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 21192-02-7 for ; Tue, 10 May 2011 18:12:49 +0000 (UTC) Received: from news.hub.org (news.hub.org [200.46.204.72]) by mail.postgresql.org (Postfix) with ESMTP id 6D2701337C5F for ; Tue, 10 May 2011 15:08:13 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id p4AI8Cqr088028 for ; Tue, 10 May 2011 15:08:12 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id p4AHtUxZ053644 for pgsql-sql@postgresql.org; Tue, 10 May 2011 14:55:30 -0300 (ADT) (envelope-from news) From: Lew X-Newsgroups: pgsql.sql Subject: Re: Dates and NULL's` Date: Tue, 10 May 2011 13:55:35 -0400 Organization: albasani.net Lines: 32 Message-ID: References: <201105100948.41392.johnf@jfcomputer.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: news.albasani.net; logging-data="+pZ/+NDTYmfGQ6uFr6dupiP1K939ZXQnEyTEL9QCd1nsW9HGWpboaSeGzYxUF7zSLb7s5cLHRTHRHUz6Br/gJGp3Uj1VM4CVLZdRpkUsBYn27CXt4Iry445kXArXSlLh"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 In-Reply-To: <201105100948.41392.johnf@jfcomputer.com> Cancel-Lock: sha1:myDXXLbw+ioQA3ezDDPBacOkO8E= To: pgsql-sql@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.51 tagged_above=-5 required=5 tests=BAYES_05=-0.5, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/75 X-Sequence-Number: 35359 On 05/10/2011 12:48 PM, John Fabiani wrote: > Hi, > Maybe this is a dumb question but if I have a date field that contains a NULL > will it show up when I ask for a where date range for the same date field. > > Where mydate>= "2011/04/01"::date and mydate<= "2011/04/30"::date > > With the above where will the NULL's be selected???? How many question marks does it take to indicate an interrogative? > I ask because I was always told that a NULL matches everything and nothing! That's not a useful viewpoint. The useful point is that NULL matches nothing. It's a simple three-valued logic with NULL standing in for UNKNOWN: The WHERE clause only selects rows for which the clause evaluates to TRUE. So in the WHERE clause, both NULL > "2011/04/01"::date and NULL <= "2011/04/30"::date will fail, and so would NULL <= "2011/04/01"::date , since none of these evaluates to TRUE. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg