Query with DateDiff Function (1 Viewer)

Eljefegeneo

Still trying to learn
Local time
Today, 15:32
Joined
Jan 10, 2011
Messages
904
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?
 

AccessMSSQL

Seasoned Programmer-ette
Local time
Today, 15:32
Joined
May 3, 2012
Messages
636
The function is IIF, not Iff. That should solve it!
 

Eljefegeneo

Still trying to learn
Local time
Today, 15:32
Joined
Jan 10, 2011
Messages
904
Just goes to show you that a simple answer can solve most problems. Can't believe that I transposed the letters. Guess my dyslexia kicked in. Thanks again, will try it.
 

Eljefegeneo

Still trying to learn
Local time
Today, 15:32
Joined
Jan 10, 2011
Messages
904
That was it! Two days of frustration gone!
 

Users who are viewing this thread

Top Bottom