Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with dates in sql query

Status
Not open for further replies.

Ovatvvon

Programmer
Feb 1, 2001
1,514
US
The Question:
Does anyone know the proper way to test for a NON-empty date field in the database and/or an Empty date field in a sql query statement?

The Problem:
I have a database that contains several fields, 3 of which are date fields. 1 is when the work request was submitted, 1 is when the work request was assigned to a technician, and the last one is when the work request was completed. I'll call them submitted, open and closed fields.

The problem is when the form tries to send a query that will pull all open record fields that have a value in them (meaning a technician has been assigned to the work request), but do not have a value in the closed field (meaning the work request is still in progress). I'm using somthing like the following:

Select * From tblWorkRequest WHERE (dateOpened <> &quot;&quot;) AND (dateClosed = &quot;&quot;);

Now, since they are date fields, the quotes won't work because they are for strings. I tried substituting &quot;&quot; with ##, but it still doesn't work.

So, the question is, does anyone know the proper way to test for a non-empty date field, or an empty date field in a sql query statement?
-Ovatvvon :-Q
 
Select * From tblWorkRequest WHERE dateOpened NOT NULL AND dateClosed NOT NULL; www.vzio.com
star.gif
/ [wink]
 
the keyword &quot;NOT&quot; didn't work. However using &quot;<>&quot; did when I was checking for the lack of a null value. But the keyword &quot;IS&quot; did work when checking for the presence of the NULL value. So I had to change it around a bit, but you definately pointed me in the right direction snowboardr.
Thanks! :) -Ovatvvon :-Q
 
Glad I could help, I forgot about is when there is NULL. www.vzio.com
star.gif
/ [wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top