Results 1 to 5 of 5
  1. #1
    yam is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    3

    Queries to retrieve records which fall between two dates

    Hi,


    I have a table with fields "Approval Date" and "Expiry Date" for each record. I want to retrieve records which fall in a period. (eg. active in 2010).

    Then I make a parameter query [EnterYear].

    [EnterYear]>=Year([Approval Date]) And [EnterYear]<=Year([Expiry Date]).

    It seems work for calendar year ( 1 Jan- 31 Dec).


    Now I want to have records for financial year period ( eg. FY 2012 is from 1 April 2012 to 31 Mar 2013). How can I do query for this kind of period?


    Example of Records in table:

    Approval Date Expiry Date
    Record(1) 1/1/2008 30/04/2009
    Record(2) 10/2/2009 9/2/2010
    Record(3) 1/1/2009 1/1/2012
    Record(4) 1/1/2010 1/1/2014
    Record(5) 1/1/2011 1/1/2012

    If User look for Active record in 2010 Financial year ( 1 April 2010 to 30 Mar 2011), the result should be Record 3,4 and 5. Please advise how to make a query.

    Regards,
    YAM
    Last edited by June7; 03-15-2013 at 02:48 AM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    Calculate the fiscal year for date fields and use those values as you have for calendar year.

    [Enter Date] BETWEEN Year(ApprovalDate) - IIf(Month(ApprovalDate)<4, 1, 0) AND Year(ExpiryDate) - IIf(Month(ExpiryDate)<4, 1, 0)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    yam is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    3
    Quote Originally Posted by June7 View Post
    Calculate the fiscal year for date fields and use those values as you have for calendar year.

    [Enter Date] BETWEEN Year(ApprovalDate) - IIf(Month(ApprovalDate)<4, 1, 0) AND Year(ExpiryDate) - IIf(Month(ExpiryDate)<4, 1, 0)

    Hi,

    Thanks for reply. As Record(3) 1/1/2009, 1/1/2012 (Approval Date, Expiry Date) is still ongoing in FY 2010, it has to be in result too. I want to have all records which is ongoing in FY 2010.


    Thanks for advise.

    YAM

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    Issue resolved?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    yam is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    3

    Red face

    Quote Originally Posted by June7 View Post
    Issue resolved?
    It is working . Thanks for help.

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

Similar Threads

  1. Subtracting Dates in Queries
    By seanpbent in forum Access
    Replies: 1
    Last Post: 02-01-2013, 04:28 PM
  2. Replies: 2
    Last Post: 11-14-2012, 04:47 PM
  3. Retrieve group records based on max value
    By wireless in forum Access
    Replies: 7
    Last Post: 02-03-2011, 03:30 PM
  4. Retrieve similar records
    By dodell in forum Queries
    Replies: 3
    Last Post: 03-31-2010, 11:48 AM
  5. Handling dates in queries
    By mrk68 in forum Access
    Replies: 4
    Last Post: 03-23-2009, 06:35 AM

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