Results 1 to 5 of 5
  1. #1
    afa is offline Novice
    Windows 8 Access 2013
    Join Date
    Feb 2016
    Posts
    22

    Access Date Criteria

    I would like to run a query with the [SalesDate] field to contain dates from the current month the report is running Date() to one year from now AND include all dates within the last month.

    For example, if I run it on 9/7/16, it will output dates from 9/1/16 to 9/30/17.
    I tried
    Between Month(Date()) And Month(Date()+365) ...does not work.

    Month(Date()) is successful in retrieving all dates within the current month the query is run but I cannot get all the dates within the last month.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    There must be an easier way than this!

    First day of month: CDate(Format(Date(),"mm") & "/01/" & Format(Date(),"yyyy"))
    Last day of month: DateAdd("m",1,[fdom])-1
    Next year: [ldom] + 365

    Put it all together in a "Between" statement

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Try:
    Code:
    ....WHERE [SalesDate] Between DateSerial(Year(Date()), Month(Date()),1) AND DateSerial(Year(Date())+1, Month(Date())+1,0)

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Brilliant!

  5. #5
    afa is offline Novice
    Windows 8 Access 2013
    Join Date
    Feb 2016
    Posts
    22
    Yup that works perfect.

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

Similar Threads

  1. Replies: 21
    Last Post: 08-16-2016, 09:46 AM
  2. Replies: 3
    Last Post: 09-10-2015, 07:36 PM
  3. Replies: 2
    Last Post: 04-02-2015, 12:45 PM
  4. Date criteria using between and form date picker
    By killermonkey in forum Queries
    Replies: 3
    Last Post: 03-21-2013, 12:44 PM
  5. Replies: 3
    Last Post: 08-21-2012, 03:05 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