Date formula help please!

  • Thread starter Thread starter golfinray
  • Start date Start date
G

golfinray

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.
 
IIf([datefield] <= DateSerial(2012,12,31),"2011-2012","2012-2013")

The above assumes that [datefield] is a DateTime datatype.
 
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.
 
Thanks, guys, worked like a charm!
--
Milton Purdy
ACCESS
State of Arkansas


Ken Snell said:
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 said:
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.


.
 
Back
Top