Query - IIf statement....

B

Bill

Hi,

When I try to run the query and I create a column on the query to put "IIF
statement". I try and it won't work properly. I am not too sure if I
understand or not. Your feedback and show me what you create "IIf
statement"

Four seasons:

1) "Spring" [Date] between 21/03/2004 to 20/06/2004
2) "Summer" - [Date] between 21/06/2004 to 29/09/2004
3) "Autumn" - [Date] between 30/09/2004 to 31/10/2004
4) "Winter" - [Date] between 01/11/2004 to 21/03/2005
5) "Two Season" (Summer and Autumn) [Date] between 21/03/2004 and
29/09/2004

I tried all five but it gives me two result not Five. Your help would be
much appreciated.

Your help would be much appreciated.
Thanks
 
M

MGFoster

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It'd probably help us more if we could see your SQL. But, here's a try:

SELECT IIf(date_column between #3/21/2004# and #6/20/2004#, "Spring",
IIf(date_column between #6/21/2004# and #9/29/2004#, "Summer",
IIf(date_column between #9/30/2004# and #10/31/2004#, "Autumn",
IIf(date_column between #11/1/2004# and #3/21/2005#, "Winter",
IIf(date_column between #3/21/2004# and #9/29/2004#,
"Two Season"))))) As Season
FROM ... etc. ...

Note: I've used USA date format.

I believe the Two Season will not show, 'cuz it will be evaluated by
Spring or Summer dates before the Two Season dates are checked.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQbUDcoechKqOuFEgEQLi6wCeMJrwUCmV2yBwTt+d4lQqv9FdMioAoP90
78CV7Mm5YES2X8f17YLzGS4Z
=EU0L
-----END PGP SIGNATURE-----

Hi,

When I try to run the query and I create a column on the query to put "IIF
statement". I try and it won't work properly. I am not too sure if I
understand or not. Your feedback and show me what you create "IIf
statement"

Four seasons:

1) "Spring" [Date] between 21/03/2004 to 20/06/2004
2) "Summer" - [Date] between 21/06/2004 to 29/09/2004
3) "Autumn" - [Date] between 30/09/2004 to 31/10/2004
4) "Winter" - [Date] between 01/11/2004 to 21/03/2005
5) "Two Season" (Summer and Autumn) [Date] between 21/03/2004 and
29/09/2004

I tried all five but it gives me two result not Five. Your help would be
much appreciated.

It'd probably help us more if we could see your SQL. But, here's a try:

SELECT IIf(date_column between #3/21/2004# and #6/20/2004#, "Spring",
IIf(date_column between #6/21/2004# and #9/29/2004#, "Summer",
IIf(date_column between #9/30/2004# and #10/31/2004#, "Autumn",
IIf(date_column between #11/1/2004# and #3/21/2005#, "Winter",
IIf(date_column between #3/21/2004# and #9/29/2004#,
"Two Season"))))) As Season
FROM ... etc. ...

Note: I've used USA date format.

I believe the Two Season will not show, 'cuz it will be evaluated by
Spring or Summer dates before the Two Season dates are checked.
 

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