SQL question

From: Carolyn Lu Wong <carolyn(at)kss(dot)net(dot)au>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: SQL question
Date: 2000-07-17 02:07:25
Message-ID: 39726A5C.B6B45856@kss.net.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Philip Warner 2000-07-17 02:18:56 Re: SQL question
Previous Message Robert B. Easter 2000-07-16 22:02:51 How to get count of rows in cursor