Re: Dates and NULL's`

From: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
To: John Fabiani <johnf(at)jfcomputer(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Dates and NULL's`
Date: 2011-05-10 20:36:45
Message-ID: 4DC9A1DD.5070700@encs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


>>> Where mydate>= "2011/04/01"::date and mydate<= "2011/04/30"::date
>>> With the above where will the NULL's be selected????
>>
>> Here is what I get when I try:
>>
>> spi=> SELECT NULL::DATE>= '2011-04-01'::DATE AND NULL::DATE<=
>> '2011-04-30'::DATE;
>> ?column?
>> ----------
>>
>> (1 row)
>>
>>
>> spi=> SELECT (NULL::DATE>= '2011-04-01'::DATE AND NULL::DATE<=
>> '2011-04-30'::DATE) IS TRUE;
>> ?column?
>> ----------
>> f
>> (1 row)
>>
>>
>> spi=> SELECT (NULL::DATE>= '2011-04-01'::DATE AND NULL::DATE<=
>> '2011-04-30'::DATE) IS FALSE;
>> ?column?
>> ----------
>> f
>> (1 row)
>>
>>
>> spi=> SELECT (NULL::DATE>= '2011-04-01'::DATE AND NULL::DATE<=
>> '2011-04-30'::DATE) IS UNKNOWN;
>> ?column?
>> ----------
>> t
>> (1 row)
> Sorry Richard, I do not understand.
>
> It looks like you are saying the NULLS will be returned too

As a summary:
============================================
(1)
null:date COMPARE 'real date'::DATE
Will always return NUll, so you will not get the record returned at all!

(2) examples he provided:

. (null:date COMPARE 'real date'::DATE) IS NULL;
. (null:date COMPARE 'real date'::DATE) IS UNKNOWN;

Null returns true.

(3) null is true/false;
returns false

Emi

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Theodore Petrosky 2011-05-10 20:51:17 Re: Dates and NULL's`
Previous Message Brent Dombrowski 2011-05-10 20:33:12 Re: Dates and NULL's`