Results 1 to 4 of 4
  1. #1
    ScottXe is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    25

    IIF statement in query

    I would like to extract the year part from a date field as a Fiscal Year field. I believe IIF statement can help in this case.



    FiscalYear: IIf([Completed]>=#01/05/2014#,DatePart("yyyy",[Completed]),(DatePart("yyyy",[Completed]))-1)

    How can I use only 01/05 without year for comparison? The completed field may contain different year dates. Thanks!

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Try using the Format function, i.e.
    Format([DateField],"mm/dd")

  3. #3
    ScottXe is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    25
    Quote Originally Posted by JoeM View Post
    Try using the Format function, i.e.
    Format([DateField],"mm/dd")
    Hi JoeM,
    Thanks for your advice that works well. What is the need to have "/" between mm and dd? I tried to remove it. Without it, it will become 4 digit comparison - xxxx vs 0501. It looks more straight forward comparison, isn't it?

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    FY: datepart("yyyy", [Completed]) + iif(datepart("m", [Completed]) >=5, 0,1)

    this is assuming your fiscal year starts on May 1

Please reply to this thread with any new information or opinions.

Similar Threads

  1. IIF Statement In Query
    By Juan4412 in forum Queries
    Replies: 2
    Last Post: 05-08-2014, 08:59 AM
  2. iif statement in a query
    By to47122 in forum Access
    Replies: 9
    Last Post: 09-16-2012, 07:32 PM
  3. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  4. Replies: 3
    Last Post: 07-10-2012, 05:23 AM
  5. If statement in Query
    By Jojojo in forum Queries
    Replies: 5
    Last Post: 11-18-2011, 03:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums