Eljefegeneo
Still trying to learn
- Local time
- Yesterday, 19:56
- Joined
- Jan 10, 2011
- Messages
- 902
I am trying to make a query using the DateDiff function. I want to determine if the date of last customer contact is less than 365, between 366 and 730 or greater than 730, thus making three categories. My objective is to get the last contact date from a related table to get one of three variables, A, B or C which would represent whether the sales contact is prime, secondary or old.
I can calculate the number of days using DateDiff, by first using Max(tblSalesContactsFinal.DateofContact) AS LastDate to get me the last contact date. Then I used DateCount: DateDiff("d",[LastDate],Date()) to get the number of days. But when I use Iff(DateDiff("d",[LastDate],Date())<365, "A", Iff(DateDiff("d",[LastDate],Date())>730, "C", "B"))
I get the error Undefined Iff In expression. I tried it with only one variable, that is Iff (Value)<365, "A", "B", but it still gives me the same error message. What am I doing wrong?
I can calculate the number of days using DateDiff, by first using Max(tblSalesContactsFinal.DateofContact) AS LastDate to get me the last contact date. Then I used DateCount: DateDiff("d",[LastDate],Date()) to get the number of days. But when I use Iff(DateDiff("d",[LastDate],Date())<365, "A", Iff(DateDiff("d",[LastDate],Date())>730, "C", "B"))
I get the error Undefined Iff In expression. I tried it with only one variable, that is Iff (Value)<365, "A", "B", but it still gives me the same error message. What am I doing wrong?