PostgreSQL: Select where timestamp is empty
I have a query that looks like the following:
SELECT * FROM table WHERE timestamp = NULL;
The timestamp column is a timestamp with time zone data type (second type in this table). This is in PostgreSQL 8.4.
What I'm trying to accomplish is to only select rows that have not had a timestamp inserted. When I look at the data in pgAdmin the field is empty and shows no value. I've tried where timestamp = NULL
, 'EPOCH'
(which you would think would be the default value), a valid timestamp of zeros (0000-00-00 00:00:00-00
, which results in a out of range error), the lowest date possible according to the docs (January 1, 4713 BC
) and a blank string (''
, which just gets a data type mismatch error). There also appears to be no is_timestamp()
function that I can use to check if the result is not a valid timestamp.
So, the question is, what value is in that empty field that I can check for?
Thanks.
EDIT: The field does not have a default value.
Solution 1:
Try timestamp is null
as i use this syntax in MySQL