A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

IIf statement



 
 
Thread Tools Display Modes
  #1  
Old February 18th, 2007, 04:27 PM posted to microsoft.public.access.queries
[email protected]
external usenet poster
 
Posts: 2
Default IIf statement

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

  #2  
Old February 18th, 2007, 05:20 PM posted to microsoft.public.access.queries
raskew via AccessMonster.com
external usenet poster
 
Posts: 370
Default IIf statement

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

wrote:
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


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200702/1

  #4  
Old February 18th, 2007, 08:00 PM posted to microsoft.public.access.queries
[email protected]
external usenet poster
 
Posts: 2
Default IIf statement

On Feb 18, 11:20 am, "raskew via AccessMonster.com" u28575@uwe
wrote:
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

wrote:
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


--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200702/1



THANK YOU BOTH,
Thats exactly what I needed.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:43 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.