Received: from acheron.rime.com.au (root@albatr.lnk.telstra.net [139.130.54.222]) by hub.org (8.10.1/8.10.1) with ESMTP id e6H2J6016111 for ; Sun, 16 Jul 2000 22:19:07 -0400 (EDT) Received: from oberon (Oberon.rime.com.au [203.8.195.100]) by acheron.rime.com.au (8.9.3/8.9.3) with SMTP id MAA20189; Mon, 17 Jul 2000 12:12:54 +1000 Message-Id: <3.0.5.32.20000717121856.022cd100@mail.rhyme.com.au> X-Sender: pjw@mail.rhyme.com.au X-Mailer: QUALCOMM Windows Eudora Pro Version 3.0.5 (32) Date: Mon, 17 Jul 2000 12:18:56 +1000 To: Carolyn Lu Wong , "pgsql-sql@postgresql.org" From: Philip Warner Subject: Re: SQL question In-Reply-To: <39726A5C.B6B45856@kss.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Archive-Number: 200007/162 At 12:07 17/07/00 +1000, Carolyn Lu Wong wrote: >I have table with the following definition: > > create table table1( > account_no int4, > start_date_tme datetime > .... > ); > >The table may contain null values for start_date_time. > >When I run the following SQL query, it fails: > > select * from table1 > where start_date_time::date >= '01/01/2000'::date > and start_date_time::date <= '01/01/2001'::date; > >I get error message 'Unable to convert null datetime to date. > >It's fine if I run the same SQL query with added condition as follows: > > select * from table1 >> where account_no = 1 > and start_date_time::date >= '01/01/2000'::date > and start_date_time::date <= '01/01/2001'::date; > >Is this a bug? Or there's an logical explaination for this? The most logical explanation is that there are no null values in start_date_time when account_no = 1. Try select count(*) from table1 where account_no = 1 and start_date_time is null; and see if you get 0. ---------------------------------------------------------------- Philip Warner | __---_____ Albatross Consulting Pty. Ltd. |----/ - \ (A.C.N. 008 659 498) | /(@) ______---_ Tel: (+61) 0500 83 82 81 | _________ \ Fax: (+61) 0500 83 82 82 | ___________ | Http://www.rhyme.com.au | / \| | --________-- PGP key available upon request, | / and from pgp5.ai.mit.edu:11371 |/