pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Emi Lu <emilu@encs.concordia.ca>
To: John Fabiani <johnf@jfcomputer.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Dates and NULL's`
Date: Tue, 10 May 2011 16:36:45 -0400
Message-ID: <4DC9A1DD.5070700@encs.concordia.ca> (raw)
In-Reply-To: <201105101024.23612.johnf@jfcomputer.com>
References: <201105100948.41392.johnf@jfcomputer.com>
	<BANLkTina8jK3f_p0xynxgzQhpL2aCUsL6A@mail.gmail.com>
	<201105101024.23612.johnf@jfcomputer.com>


>>> 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






view thread (10+ messages)  latest in thread

Message-ID: <4DC9A1DD.5070700@encs.concordia.ca>
Permalink:  ../4DC9A1DD.5070700@encs.concordia.ca/
Also on:    postgresql.org/message-id/4DC9A1DD.5070700@encs.concordia.ca

 · 

reply

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: emilu@encs.concordia.ca, johnf@jfcomputer.com
  Subject: Re: Dates and NULL's`
  In-Reply-To: <4DC9A1DD.5070700@encs.concordia.ca>

* 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