Results 1 to 14 of 14
  1. #1
    toilettenseife is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    9

    Help! Date Criteria: Between Last 12 Months

    Hello Access Community,



    I am trying to create a criteria that returns records in the date range of last month and the 11 months before it.

    Here is my attempt: Between DateSerial(year(DateAdd("y",-1,Date())),Month(Date()),1) and DateSerial(year(Date()),month(DateAdd("m",-1,Date())),30)

    The two sections work independently. However, when I tie them together with "Between" and "And," it doesn't work.

    Is there a better way to get records in this date range?

    Thanks!

  2. #2
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    I dont see why you should have to convert the Date to Serial in order to work this.

  3. #3
    toilettenseife is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    9
    So, something like this? Between Month(Date())/1/year(DateAdd("y",-1,Date())) and Month(DateAdd("m",-1,Date()))/30/year(Date())

    I got an error: inconsistent datatypes: expected Date got BINARY_DOUBLE

  4. #4
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Between DateAdd("yyyy",-1,Date()) And DateAdd("m",-1,Date())

  5. #5
    toilettenseife is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    9
    Between DateAdd("y",-1,Date()) And DateAdd("m",-1,Date()) doesn't return any records. Between #11/1/2014# And #10/31/2015# returns 3,546 records so I know there are records there.

  6. #6
    toilettenseife is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    9
    Wait......

  7. #7
    toilettenseife is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    9
    I think it worked......

  8. #8
    toilettenseife is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    9
    Well, not exactly but I think I'm on the right track now. Thanks!

  9. #9
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    I think you neeed to use "yyyy" instead of "y"
    http://www.techonthenet.com/access/f...te/dateadd.php

  10. #10
    toilettenseife is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    9
    I started to get returns after I changed it to "yyyy." However, Between DateAdd("yyyy",-1,Date()) And DateAdd("m",-1,Date()) gives me a date range equivalent to Between Date()-365 And Date I need whole months. Last month + the previous 11. Example: If I ran it today I would get the equivalent of Between #11/1/2014# And #10/31/2015#


  11. #11
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Oh, well in that case you will probaly need to use DateSerial. im such a doofus.

  12. #12
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Try

    Between DateSerial(Year(Date())-1,Month(Date()),1) And DateSerial(Year(Date()),Month(Date()),0)

  13. #13
    toilettenseife is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    9
    Sir you are a genius and a gentleman. It works! Thanks!

  14. #14
    toilettenseife is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Nov 2015
    Posts
    9
    Now, how do you mark this post as solved?

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

Similar Threads

  1. Replies: 5
    Last Post: 05-28-2015, 06:58 AM
  2. Get data - 3 months to Date
    By Shilabrow in forum Queries
    Replies: 3
    Last Post: 06-23-2014, 12:04 PM
  3. Replies: 3
    Last Post: 02-23-2014, 02:06 PM
  4. Criteria for last 12 months
    By libraccess in forum Queries
    Replies: 6
    Last Post: 05-07-2012, 07:33 PM
  5. Query criteria, add 5 months to date
    By thart21 in forum Queries
    Replies: 1
    Last Post: 03-29-2010, 05:09 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