datevalue - unexpected results

G

Guest

I have a query where I want to take the [exposed date] and if it's less than
or equal to now() then have it return "exposed". On the other side, if the
[exposed date] is greater than or equal to now() I want it to return "the
month and year". I'm getting unexpected results. On half of the results it's
working correctly but the other half it doesn't.

Could you please pass down some wisdom of where I'm going wrong. Thank you
as always!

Bucket2: IIf([exposed date]<=DateValue(Now()),"Exposed",IIf([exposed
date]>=DateValue(Now()),[exposed date], "mm/yyyy" ))
 
J

John Spencer

Bucket2: IIf([exposed date]<=Date(), "Exposed",
IIf([exposed date]>Date(), Format([exposed date], "mm/yyyy" ), Null))

I used Date() instead of DateValue(Now()) because Date() = DateValue(Now())
I Changed => to just > in the second IIF since you use <= in the first
I used the Format function to format the date (assumption is your were
trying to do this)
I added Null as the false outcome of the second IIF - not needed, but just
cleaner to my eyes.
 
G

Guest

Okay, I figured it out. My [exposed date] was a calculation field and so I
just combined that calculation into my statement and it works perfect!

Keith
 
M

Marshall Barton

Keith said:
I have a query where I want to take the [exposed date] and if it's less than
or equal to now() then have it return "exposed". On the other side, if the
[exposed date] is greater than or equal to now() I want it to return "the
month and year". I'm getting unexpected results. On half of the results it's
working correctly but the other half it doesn't.

Could you please pass down some wisdom of where I'm going wrong. Thank you
as always!

Bucket2: IIf([exposed date]<=DateValue(Now()),"Exposed",IIf([exposed
date]>=DateValue(Now()),[exposed date], "mm/yyyy" ))


Try this:

Bucket2: IIf([exposed date] <= Date(), "Exposed",
Format([exposed date], "mm/yyyy" )
 

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