From: Lew <noone@lewscanon.com>
To: pgsql-sql@postgresql.org
Subject: Re: Dates and NULL's`
Date: Tue, 10 May 2011 13:55:35 -0400
Message-ID: <iqbu6i$n6j$1@news.albasani.net> (raw)
In-Reply-To: <201105100948.41392.johnf@jfcomputer.com>
References: <201105100948.41392.johnf@jfcomputer.com>
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:
<http://www.postgresql.org/docs/9.0/interactive/functions-logical.html;
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: noone@lewscanon.com
Subject: Re: Dates and NULL's`
In-Reply-To: <iqbu6i$n6j$1@news.albasani.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox