From: golfinray on
I can't quite figure out the syntax of what I need. I need IIF([date field]<=
"12/31/2012), "2011-2012","2012-2013") I think it can be done with dateserial
but I can't get it to work.
--
Milton Purdy
ACCESS
State of Arkansas
From: Ken Snell on
IIf([datefield] <= DateSerial(2012,12,31),"2011-2012","2012-2013")

The above assumes that [datefield] is a DateTime datatype.

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"golfinray" <golfinray(a)discussions.microsoft.com> wrote in message
news:6009504E-DA9F-4780-B348-6E4528E4DC8B(a)microsoft.com...
>I can't quite figure out the syntax of what I need. I need IIF([date
>field]<=
> "12/31/2012), "2011-2012","2012-2013") I think it can be done with
> dateserial
> but I can't get it to work.
> --
> Milton Purdy
> ACCESS
> State of Arkansas


From: fredg on
On Fri, 26 Feb 2010 08:44:07 -0800, golfinray wrote:

> I can't quite figure out the syntax of what I need. I need IIF([date field]<=
> "12/31/2012), "2011-2012","2012-2013") I think it can be done with dateserial
> but I can't get it to work.

You need to wrap the date criteria within the date delimiter symbol #.
As written, Access is looking for a string "12/31/2012".
And you don't need DateSerial.

IIf([DateField] <= #12/31/2012#,"2011-2012","2012-2013")

You could also use:
IIf Year([DateField])<= 2012, 2011-2012,2012-2013)

The above both assume [DateField] is a Date/Time datatype field.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
From: golfinray on
Thanks, guys, worked like a charm!
--
Milton Purdy
ACCESS
State of Arkansas


"Ken Snell" wrote:

> IIf([datefield] <= DateSerial(2012,12,31),"2011-2012","2012-2013")
>
> The above assumes that [datefield] is a DateTime datatype.
>
> --
>
> Ken Snell
> http://www.accessmvp.com/KDSnell/
>
>
> "golfinray" <golfinray(a)discussions.microsoft.com> wrote in message
> news:6009504E-DA9F-4780-B348-6E4528E4DC8B(a)microsoft.com...
> >I can't quite figure out the syntax of what I need. I need IIF([date
> >field]<=
> > "12/31/2012), "2011-2012","2012-2013") I think it can be done with
> > dateserial
> > but I can't get it to work.
> > --
> > Milton Purdy
> > ACCESS
> > State of Arkansas
>
>
> .
>