Results 1 to 3 of 3
  1. #1
    BigVinnie is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    4

    Query to get last week's data

    Hello all,



    I have a select query where I always want to retrieve the data from last week (Monday to Sunday) without inputting the date in the query.
    The criteria is currently BETWEEN #04/02/2018 AND #11/02/2018. Rather than replacing a hard coded date each week I want to use an expression instead. So if I was running the query on Wed 20th Feb I want to return results for the week commencing Mon 11th Feb.

    From searching on the Internet it appears that I requires a combination of date functions. I tried Between Date() - ( 6 + Weekday(Date(), 2)) AND Date() - Weekday(Date(), 2) but this is not returning the right results.

    I am new to this type of query so any help would be much appreciated.

    Many Thanks

    Vinnie

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    so basically you want to run the query for last week, regardless of when you run it this week?

    your formula works for me - it returns 4th-10th- my only comment is you say 'BETWEEN #04/02/2018 AND #11/02/2018' - that is 8 days, not 7 - and today is only the 17th we haven't reached the 20th yet. I f was to run on the 20th it returns 11th-17th

  3. #3
    BigVinnie is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    4
    Thanks for your response. It seems to be working now! Database having a moment

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

Similar Threads

  1. Replies: 26
    Last Post: 11-05-2015, 01:58 PM
  2. Replies: 9
    Last Post: 06-19-2015, 03:37 PM
  3. Replies: 1
    Last Post: 01-28-2015, 12:19 PM
  4. Replies: 3
    Last Post: 01-21-2015, 02:40 PM
  5. Query help to summarize data by work week
    By saseymour in forum Queries
    Replies: 4
    Last Post: 07-18-2013, 07:29 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