Date Comparison

D

Dallas Miller

Can anyone help? I have an Access 2002 table with two
date fields called date1 and date2. I need to compare
these dates with today's date to see if the record is
active. I need to code an expression like this:

IIF([date1] >= date() and [date2] <= date
(), 'Active','Inactive')

I get "#Error" displayed in the field.

Any help would be greatly appreciated?

Thanks,
Dallas
 
J

James Goodman

Try:

IIf(DateDiff("d",[date1],Date())>1 And
DateDiff("d",[date2],Date())<1,"Active","Inactive")

You might need to swap the orders in the DateDiff function to your needs...
 
D

Dallas Miller

Joseph,

the fields are date fields with short date format.

Thanks for your help.

Dallas

-----Original Message-----
Dallas said:
Can anyone help? I have an Access 2002 table with two
date fields called date1 and date2. I need to compare
these dates with today's date to see if the record is
active. I need to code an expression like this:

IIF([date1] >= date() and [date2] <= date
(), 'Active','Inactive')

I get "#Error" displayed in the field.

Any help would be greatly appreciated?

Thanks,
Dallas

First question: Are the date1 & date2 fields date type fields or are
they text fields with date information?

No offence, but this is a rather common problem.

--
Joseph E. Meehan

26 + 6 = 1 It's Irish Math



.
 

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