Results 1 to 4 of 4
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    last twelve months

    All; using access 2010. I have a payroll table that keeps data for up to five years. I am trying to get a query of the last twelve months of payroll data. I am using the code in the criteria:

    Code:
    >= DateAdd("yyyy", -1, Date())
    It returns only 11 months:



    Code:
    qryPayroll
    P Num P State SDate
    435 NC 4/1/2015
    435 NC 5/1/2015
    435 NC 6/1/2015
    435 NC 7/1/2015
    435 NC 8/1/2015
    435 NC 9/1/2015
    435 NC 10/1/2015
    435 NC 11/1/2015
    435 NC 12/1/2015
    435 NC 1/1/2016
    435 NC 2/1/2016
    I am missing March 2015 (3/1/2015). Is it because we're in that month? I want to include March 2015 to get a full 12 months since the data only updates on a monthly basis; so March 2016 would not be included yet. What changes to the code do I need pls?
    Thanks

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Maybe try:
    Code:
    >= DateAdd("m", -13, Date())
    I don't have Access installed on this computer, so I can't test it.

  3. #3
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,931
    Given the date, today is 7th March so 1st Match last year is < today-1 year. Would think ssanfu's solution will work

  4. #4
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    This worked! thanks so much to you all.

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

Similar Threads

  1. How to print From and to Months
    By talktime in forum Reports
    Replies: 2
    Last Post: 09-18-2014, 08:12 PM
  2. Replies: 3
    Last Post: 02-23-2014, 02:06 PM
  3. Criteria for last 12 months
    By libraccess in forum Queries
    Replies: 6
    Last Post: 05-07-2012, 07:33 PM
  4. Grouping info for the last twelve months
    By herbc0704 in forum Queries
    Replies: 2
    Last Post: 09-14-2011, 10:30 AM
  5. Counting Months
    By xzero1484 in forum Queries
    Replies: 1
    Last Post: 02-21-2011, 03:49 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