|
-
March 25th, 2004, 08:43 AM
#1
SQL select statement, checking for null values in a Date Field in database.
I am using the select statement in SQL, I am trying to pull all records with a null value in the date field. Here is the current code i am using:
<%sql = "select d_susp, idea_no, s_name, title, eval_off, comments from suggest where action = 'A' and authority = 'Y' and (D_f_a_orl = '' or isnull(d_f_a_orl)) order by d_susp"%>
That you are seeing inside the parenthesis is 2 different ways i tried to pull records if that date field had a null value. First i tried 2 single quotes (that isnt a double quote in the code, but it looks like it on this page), then someone told me to try "< 1" and that didnt work, so i took that out, then i made a blank variable and checked to see if they were equal, that didnt workso i took that out, then i used isnul.
I know the other variables like action = 'A' and authority = 'Y' work because i have about 7 other SQL statements right before that searching using those as fields as criteria. In this sql statement the only difference is the d_f_a_orl field. In the other sql statements, i compared dates as in date() < d_f_a_or, but i have not tried to see if a date field has a null value. Is thier a special operator i have to use to complete this task? The error i get is this:
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
/suggest/report2.asp, line 473
line 473 is the rs.execute statement on the next line. Hope you can help.
~Derrick
Last edited by derricks; March 25th, 2004 at 08:48 AM.
-
March 25th, 2004, 10:11 AM
#2
Try: (D_f_a_orl & '' = '')
-
March 25th, 2004, 10:45 AM
#3
Hi
did you try this :
Code:
sql = "select d_susp, idea_no, s_name, title, eval_off, comments from suggest where action = 'A' and authority = 'Y' or isnull(d_f_a_orl) order by d_susp
-
March 26th, 2004, 06:47 AM
#4
In MS-Access Date field cannot store blank string because of this reason you cannot check date field with blank string.
For overcome your problem change your query to following:
select d_susp, idea_no, s_name, title, eval_off, comments from suggest where action = 'A' and authority = 'Y' and D_f_a_orl IS NULL order by d_susp
Enjoy,
Gurdarshan Singh
L.S.E. (Project Lead)
InterGlobe Technologies Pvt. Ltd.
Mobile #: 9891397798 (India)
[email protected]
[email protected]
Always Think Positive whatever may be the Situation.
Please rate my suggestion/response if you find it suitable or fulfill your requirement.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|