[SQL] Handling NULL Dates

From: "Gary MacMinn" <G(dot)MacMinn(at)nca(dot)gov(dot)au>
To: pgsql-sql(at)postgreSQL(dot)org
Subject: [SQL] Handling NULL Dates
Date: 1999-11-15 05:43:12
Message-ID: s830384a.011@syd_aux.nca.gov.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello All,

I'm trying to find out if PostgreSQL has a function like NVL that replaces null values with a default?

I have a table with datetime fields, some of which are null. I'm trying to extract the date and time components with the date() and time() functions but the null values break these functions.

If NVL is not there, could anyone suggest alternatives?

TIA,
Gary MacMinn

================
Table = test1
+----------------------------------+----------------------------------+-------+
| Field | Type | Length|
+----------------------------------+----------------------------------+-------+
| t1 | text | var |
| d1 | datetime | 8 |
+----------------------------------+----------------------------------+-------+

Query : SELECT t1, date(d1) from test1; //The date() function breaks if the d1 field is not set.

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 1999-11-15 06:10:51 Re: [SQL] nulls and datetime
Previous Message Gary MacMinn 1999-11-15 05:28:19 Re: [SQL] how can tell if a column is a primary key?