Question

I have a table and a query to find specific rows from the table. The table contains a column called DueDate which contains a date as a short text. In some cases due date is not applicable so for some situations it contains the string "N/A". What I want to do is the use the expression Expr1: DateDiff("m";CDate([DueDate]);Date()) in a where statement with a criteria <1. But for the NA fields it gives errors. How can I handle this. Is it possible to use iif statements in criteria.

Was it helpful?

Solution

You can use IIf expressions in a WHERE clause, but I suggest you consider this Switch expression instead. It returns False when DueDate = 'N/A', True when the DateDiff expression returns a value less than 1 month, and Null otherwise.

WHERE Switch
    (
        DueDate = 'N/A', False,
        DateDiff('m',CDate([DueDate]),Date()) < 1, True
    ) = True

OTHER TIPS

Filter those record with

where DueDate <> 'N/A'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top