Thursday, March 29, 2012

Comparing to DateTimes in SQL-Select-Statement when one Date can be null

Hello!

I have a field "End" in my database that is mapped as DateTime and allows nulls. Now I want to do a SQL-Select (in a SqlDataSource) like

SELECT * FROM My_Table Where (([End] = @.EndDate) OR ([End] =null))


@.EndDate is a valid DateTime, but the second OR condition doesn't work.

What is the best way to check if the [End]-field is empty or null?

Thank you very much!

Try this: [End] IS NULL

No comments:

Post a Comment