Query criteria - Looking for 5 weeks from this week

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GDC1970
    New Member
    • Oct 2014
    • 17

    Query criteria - Looking for 5 weeks from this week

    I need the criteria to pull all dates for five weeks from this week.

    I am using the following for query criteria and it works, but now that the year is ending, it does not work.

    Code:
    Year([Activity Date])*53+DatePart("ww",[Activity Date])= Year(Date())*53+DatePart("ww",Date())+5
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi

    I do not understand why you are multiplying by 53, but I suspect the criteria fails when the [Activity Date] changes to January next year because the Date part changes from 52/53 in the previous week to 1 and is therefore less than DatePart (week) of to-day.

    Without knowing what you are trying to do or anything about your data, would this criteria be of any use

    Code:
    [Activity Date] = DateAdd("ww", 5, Date())
    ??


    MTD

    Comment

    • GDC1970
      New Member
      • Oct 2014
      • 17

      #3
      Thank you for your assistance.
      That works but it only gives me all my activity dates on Friday 5 weeks out. I need it to show me all dates Monday through Friday 5 weeks out.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Use less than or equal to instead of equal to.

        Comment

        • GDC1970
          New Member
          • Oct 2014
          • 17

          #5
          It does not go into next year since the weeks start over. 1-52

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            I know, that's why Mike suggested using DateAdd. And if you wanted stuff in between, that's why I suggested using less than or equal to in addition to his DateAdd.

            Comment

            Working...