iif statement

A

alecgreen

Hi

I want to use an IIf statement to decide if a date field is between
today date and up 10 day ago. I figure the statement would be
something like this: result:iif([date] is between date() and date()
+10,"true","false") but this doesn't work!

Any ideas please

Alec
 
S

Stefan_889_12

Hi Alec,

try this:
My_Result: IIf([My_date]>Date() And [My_date]<Date()+10,"true","false")
Please note that Date is reserved word in Access.

Stefan.
 
R

Ron2006

I think you have reversed your logic.

To compute a date that is 10 days ago from today then you SUBTRACT 10
not add it.

The test should be:

result:iif([lookedatdate] between date()-10 and date
(),"true","false")

Ron
 
M

MJ

AlecGreen,

You are close on your IIF, except you need to subtract to check a date in
the past. As your idea is written you would be check your date between today
and 10 days in the future.

It should be: iif([YourDate] is between date() and
(date()-10),"true","false")

Hope this helps out.
 
R

Ron2006

I have never actually tested it, but shouldn't the earlier date ALWAYS
be the first date mentioned?

I guess it all depends on how the between function actually performs
the tests.

Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top