IFF Statement

G

Guest

Here is the scenario. I have a list of numbers and due dates. I need to
create a query and an IIF statement. The IIF statement has to say:

iif([number list]=**-****1, "12/31/2006")

number list
12-23121
32-12542
42-12541

Than I have due dates:
all numbers ending on "1" due date is 12/31/2006
all numbers ending on "2" due date is 12/31/2007

My question is what wildcard can I use to remplace the "???" on my
expression? Or is there another way to complete my IIF statement?
 
R

Rick B

Just use the "Right" function to grab the right digit of a field.

It seems rather odd to use a digit in a number to represent a due date,
though.
 
T

Tom Ellison

Dear Gloria:

Your "number list" contains strings. You want to look at the last
character. Use Right([number list], 1) to get this. Convert that to an
integer like this:

CInt(Right([number list], 1))

Use DateAdd to add this many years to 12/31/2005.

DateAdd("yyyy", CInt(Right("12-99997", 1)), CDate("12/31/2005"))

This yields12/31/2012

Sound good?

Tom Ellison
 
G

Guest

You could use the RIGHT$ function e.g.
IIF(RIGHT$(CStr(MyNumber),1)="1",...,...)

-Dorian
 
G

Guest

Thanks for your help

Rick B said:
Just use the "Right" function to grab the right digit of a field.

It seems rather odd to use a digit in a number to represent a due date,
though.

--
Rick B



Gloria said:
Here is the scenario. I have a list of numbers and due dates. I need to
create a query and an IIF statement. The IIF statement has to say:

iif([number list]=**-****1, "12/31/2006")

number list
12-23121
32-12542
42-12541

Than I have due dates:
all numbers ending on "1" due date is 12/31/2006
all numbers ending on "2" due date is 12/31/2007

My question is what wildcard can I use to remplace the "???" on my
expression? Or is there another way to complete my IIF statement?
 
G

Guest

Thanks for your help

Tom Ellison said:
Dear Gloria:

Your "number list" contains strings. You want to look at the last
character. Use Right([number list], 1) to get this. Convert that to an
integer like this:

CInt(Right([number list], 1))

Use DateAdd to add this many years to 12/31/2005.

DateAdd("yyyy", CInt(Right("12-99997", 1)), CDate("12/31/2005"))

This yields12/31/2012

Sound good?

Tom Ellison


Gloria said:
Here is the scenario. I have a list of numbers and due dates. I need to
create a query and an IIF statement. The IIF statement has to say:

iif([number list]=**-****1, "12/31/2006")

number list
12-23121
32-12542
42-12541

Than I have due dates:
all numbers ending on "1" due date is 12/31/2006
all numbers ending on "2" due date is 12/31/2007

My question is what wildcard can I use to remplace the "???" on my
expression? Or is there another way to complete my IIF statement?
 
G

Guest

Thanks for your help

mscertified said:
You could use the RIGHT$ function e.g.
IIF(RIGHT$(CStr(MyNumber),1)="1",...,...)

-Dorian

Gloria said:
Here is the scenario. I have a list of numbers and due dates. I need to
create a query and an IIF statement. The IIF statement has to say:

iif([number list]=**-****1, "12/31/2006")

number list
12-23121
32-12542
42-12541

Than I have due dates:
all numbers ending on "1" due date is 12/31/2006
all numbers ending on "2" due date is 12/31/2007

My question is what wildcard can I use to remplace the "???" on my
expression? Or is there another way to complete my IIF statement?
 
G

Guest

thanks for your help

mscertified said:
You could use the RIGHT$ function e.g.
IIF(RIGHT$(CStr(MyNumber),1)="1",...,...)

-Dorian

Gloria said:
Here is the scenario. I have a list of numbers and due dates. I need to
create a query and an IIF statement. The IIF statement has to say:

iif([number list]=**-****1, "12/31/2006")

number list
12-23121
32-12542
42-12541

Than I have due dates:
all numbers ending on "1" due date is 12/31/2006
all numbers ending on "2" due date is 12/31/2007

My question is what wildcard can I use to remplace the "???" on my
expression? Or is there another way to complete my IIF statement?
 

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