Page 1 of 1

Working with null dates

Posted: Thu 17 Mar 2011 23:24
by JORGEMAL
I have a table with a date field which can be null, such a table now has rows with valid date values and null values too. I need to build a query in C# to get all rows that have null values in the date field but I have not been able to achieve it. It is something like this:

strQuery = "SELECT * FROM sources WHERE src_date = NULL ORDER BY src_name"

I have tried using PgSqlTimeStamp.Null without success.
What is the correct way to write this query statement?

With respect,
Jorge Maldonado

Posted: Fri 18 Mar 2011 08:55
by Shalex
Please use the following query:
"SELECT * FROM sources WHERE src_date IS NULL ORDER BY src_name" .

Posted: Fri 18 Mar 2011 14:48
by JORGEMAL
I appreciate your answer.
So, would PgSqlTimeStamp.Null be useful to set a NULL value to a date field?

Regards,
Jorge Maldonado

Posted: Fri 18 Mar 2011 14:56
by Shalex
We will investigate the possibility of using PgSqlTimeStamp.Null in this case and post here about the results.

Posted: Mon 21 Mar 2011 13:50
by Shalex
By default, PostgreSQL does not allow using the NULL parameter (the expression = NULL clause). Please refer to http://www.postgresql.org/docs/current/ ... rison.html.