Results 1 to 5 of 5
  1. #1
    FL0XN0X is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Location
    Belgium
    Posts
    84

    Query showing only this week days

    Dear,

    I have got a query which shows the upcoming 7 days, build using the crtiteria:

    Click image for larger version. 

Name:	this week only.png 
Views:	18 
Size:	1.8 KB 
ID:	32798

    Question
    1) How to adjust the query criteria to show this week days, starting on Monday till Friday ? (thus when I run the query on whatever day of the week, it should only show the currents week days)
    2) How to adjust the query criteria to show next week days, starting on next week Monday till next week Friday ? (thus when I run the query on whatever day of the week, it should only show the week days of next week)

    Thanks in advance.
    Kind regards,


    Bart

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Calculate the Monday of the week Datum is in and the Monday of the week Date() is in.

    Like:

    SELECT * FROM table WHERE 2-Weekday(Datum)+Datum = 2-Weekday(Date())+Date();

    Next Week:

    SELECT * FROM table WHERE 2-Weekday(Datum)+Datum = 2-Weekday(Date())+Date()+7;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    FL0XN0X is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Location
    Belgium
    Posts
    84
    only one line of code, but I do not understand the equation :-(.

    2-Weekday(Datum) is an integer but then you add Datum .... I do not understand. Can you please explain ?

  4. #4
    FL0XN0X is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Location
    Belgium
    Posts
    84
    Hey June7,

    I found this solution which I DO understand :-)

    WHERE ((DatePart("ww",Kalender.Datum,2)=DatePart("ww",Da te(),2))) AND Year(Kalender.Datum)=year(Date())

    Anyhow, I'd like to understand what you've come up with .....Can yo uplease elaborate a bit?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    I found it. Bing: Access calculate Monday current week

    I have seen more than one version of the formula.

    Your DatePart() might not provide what you want for the beginning and ending of the year. You said you want a Mon-Fri period. For instance, 12/31/2018 is on Monday and it is in week 53. Whereas 1/1/2019 will return as week 1. Should those two days actually capture in the same week?

    Can see this in the VBA immediate window:

    ?DatePart("ww",#12/31/2018#)
    53
    ?DatePart("ww",#1/1/2019#)
    1
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 4
    Last Post: 07-15-2014, 01:58 PM
  2. Replies: 2
    Last Post: 12-31-2013, 08:19 AM
  3. Counting Days of the Week
    By losingmymind in forum Reports
    Replies: 10
    Last Post: 12-23-2013, 03:30 PM
  4. Storing Multiple Days of the Week in a Yes/No Format
    By TheMachine in forum Database Design
    Replies: 2
    Last Post: 05-14-2013, 12:46 PM
  5. How to Calculate days of the week
    By djclntn in forum Database Design
    Replies: 3
    Last Post: 02-26-2011, 11:10 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