IIf statement

T

tanderson97

Hi, I'm pretty new to this and am trying to make a multiple IIF
statment work. I'm trying to create a date based on current date and a
constent month and day. I want to create expiration date that is bi
annual ODD on 3-31 of the next odd year.
This is what I have ..what am I doing wrong.
AptExpDate: IIf(Year(Date()) Mod 2=0 ,"03-31-" & Year(Date())
+1,IIf((Year(Date()) <> Mod 2=0) and ((Month(Date())< 4), "03-31-" &
Year(Date()),"03-31-" & Year(Date())+2
Please help I'm stuck
I keep getting errors about not the correct number of arguments or not
the correct opening or closing ( or[
Thanks, Tim
 
R

raskew via AccessMonster.com

Hi Tim:

'From the debug (immediate) window
? dateserial(year(date()) + switch(year(date()) mod 2 = 0, 1, month(date())<4,
0, true, 2), 3, 31)
3/31/07

'Explanation: The Switch() function is generally less messy than nested
Iif's.
'year(date()) mod 2 = 0 indicates it's currently an even numbered year, so +
1
'month(date())<4 indicates (based on first statement) that's an odd numbered
year, so if current date less than 1 April add 0 else add 2

HTH - Bob

Hi, I'm pretty new to this and am trying to make a multiple IIF
statment work. I'm trying to create a date based on current date and a
constent month and day. I want to create expiration date that is bi
annual ODD on 3-31 of the next odd year.
This is what I have ..what am I doing wrong.
AptExpDate: IIf(Year(Date()) Mod 2=0 ,"03-31-" & Year(Date())
+1,IIf((Year(Date()) <> Mod 2=0) and ((Month(Date())< 4), "03-31-" &
Year(Date()),"03-31-" & Year(Date())+2
Please help I'm stuck
I keep getting errors about not the correct number of arguments or not
the correct opening or closing ( or[
Thanks, Tim
 
M

Marshall Barton

Hi, I'm pretty new to this and am trying to make a multiple IIF
statment work. I'm trying to create a date based on current date and a
constent month and day. I want to create expiration date that is bi
annual ODD on 3-31 of the next odd year.
This is what I have ..what am I doing wrong.
AptExpDate: IIf(Year(Date()) Mod 2=0 ,"03-31-" & Year(Date())
+1,IIf((Year(Date()) <> Mod 2=0) and ((Month(Date())< 4), "03-31-" &
Year(Date()),"03-31-" & Year(Date())+2


DateSerial(IIf(Year(Date()) Mod 2 = 0 , Year(Date())+1,
IIf(Month(Date()) < 4, Year(Date()), Year(Date())+2)),
3, 31)
 
T

tanderson97

Hi Tim:

'From the debug (immediate) window
? dateserial(year(date()) + switch(year(date()) mod 2 = 0, 1, month(date())<4,
0, true, 2), 3, 31)
3/31/07

'Explanation: The Switch() function is generally less messy than nested
Iif's.
'year(date()) mod 2 = 0 indicates it's currently an even numbered year, so +
1
'month(date())<4 indicates (based on first statement) that's an odd numbered
year, so if current date less than 1 April add 0 else add 2

HTH - Bob

Hi, I'm pretty new to this and am trying to make a multiple IIF
statment work. I'm trying to create a date based on current date and a
constent month and day. I want to create expiration date that is bi
annual ODD on 3-31 of the next odd year.
This is what I have ..what am I doing wrong.
AptExpDate: IIf(Year(Date()) Mod 2=0 ,"03-31-" & Year(Date())
+1,IIf((Year(Date()) <> Mod 2=0) and ((Month(Date())< 4), "03-31-" &
Year(Date()),"03-31-" & Year(Date())+2
Please help I'm stuck
I keep getting errors about not the correct number of arguments or not
the correct opening or closing ( or[
Thanks, Tim


THANK YOU BOTH,
Thats exactly what I needed.
 

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