Results 1 to 2 of 2
  1. #1
    RJ13 is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    1

    Last Weeks Data on a Monday Help!!

    Hi Guys,



    Some help here please. I have a data set with load of dates and need some SQL to show only last weeks data.

    This will be run on a Monday so I need see all records from the previous Mon-Sun please

    Thanks in advance

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    513
    You can calculate the dates for the previous week like so
    Code:
    WHERE [some_date_field] >= Date()-Weekday(Date(),2)-6 AND [some_date_field] < Date()-Weekday(Date(),2)+1
    Date()-Weekday(Date(),2)-6 = the monday of the previous week
    Date()-Weekday(Date(),2)+1 = the monday of the current week
    So the code above is filtering down to the dates greater than or equal to 12:00AM last monday and before 12:00AM the current monday.

    *Side note that date fields are date+time fields, so just remember to that into account when working with date fields. It might display March 22, 2020 but it could actually equal #March 22, 2020 11:17:31 AM#.

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

Similar Threads

  1. Replies: 4
    Last Post: 01-08-2015, 07:54 AM
  2. Combine Multiple Weeks of Data
    By Rustin788 in forum Queries
    Replies: 1
    Last Post: 09-24-2014, 08:40 AM
  3. Replies: 7
    Last Post: 04-22-2013, 08:01 AM
  4. Replies: 3
    Last Post: 11-22-2011, 11:06 AM
  5. Comparing consecutive weeks data
    By foamcows in forum Queries
    Replies: 1
    Last Post: 08-16-2011, 08:20 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
  •  
Tech Forums: Microsoft Office Forums