J
John F
I need to include a criterion in a query that is TRUE if a date field is
between two dates. But the date field can be NULL in which case the
criterion should be FALSE.
If I use the expression in the criteria cell: >=dateA AND <(dateB+1)
(where dateA and dateB are text fields in a parameter form, but just writen
here as dateA and dateB for simplicity)
This seems to do what I want, but it seems sloppy because the field can be
null. Is this an acceptable thing to do?
If not, I was considering the use of an IIF statement with IsNull:
IIF(IsNull(dtmField), FALSE, (dtmField>=dateA AND dtmField<=dateB))
I understand that regardless of whether IsNull(dtmField) is true or false,
both the true result and false result of the IIF statement will be evaluated.
If that is true, I think I would get an error if dtmField is null, but I am
using it in the expression with dateA and dateB.
What is the best thing to do?
Thanks,
John
between two dates. But the date field can be NULL in which case the
criterion should be FALSE.
If I use the expression in the criteria cell: >=dateA AND <(dateB+1)
(where dateA and dateB are text fields in a parameter form, but just writen
here as dateA and dateB for simplicity)
This seems to do what I want, but it seems sloppy because the field can be
null. Is this an acceptable thing to do?
If not, I was considering the use of an IIF statement with IsNull:
IIF(IsNull(dtmField), FALSE, (dtmField>=dateA AND dtmField<=dateB))
I understand that regardless of whether IsNull(dtmField) is true or false,
both the true result and false result of the IIF statement will be evaluated.
If that is true, I think I would get an error if dtmField is null, but I am
using it in the expression with dateA and dateB.
What is the best thing to do?
Thanks,
John