Results 1 to 8 of 8
  1. #1
    tony30 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    13

    Help for query thatl find events that took place LAST two weeks

    Please help me with this query:
    I have this expression from Microsoft help :



    Year([SalesDate])* 53 + DatePart("ww", [SalesDate]) = Year(Date())*53 + DatePart("ww", Date()) - 1

    which Returns records of transactions that took place during the last week. A week starts on Sunday and ends on Saturday.
    It works fine, I tried to modify the expression for the "last two weeks", using -2 thinking that will do the trick, it does not work. Can someone help me modifying this expression? why does not work? any suggestions?
    Thank you so much
    PD: My table is simple, listing events that take place in the past, field is CheckinDate, table is TblBookings
    Tony30

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I attached a screenshot using your expression example & it works for me.
    In my query the Date field is named 'InspectionDate' - you'll have to change that.
    the other fields in my query are off to the left so they are not showing.

    See if you can use this logic in your query to make it work. Let us know if you have problems with it.
    Attached Thumbnails Attached Thumbnails QueryDesign.JPG  

  3. #3
    tony30 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    13

    Red face Thank you!!

    I just forget to include the operator<.
    It works fine now

  4. #4
    tony30 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    13
    Dear Robeen:\
    I am sorry to report that it does not work, I have the rsults attached there are a few that are the outside interval "last two weeks"' interval should be between 9/23/2012 and 10/6/12 and
    I have quite a few outside the range.
    Any thoughts?
    Thanks
    I thought it was the operator but it is something else taht is not working...
    Thank you aClick image for larger version. 

Name:	Capture1.JPG 
Views:	13 
Size:	53.5 KB 
ID:	9457gain..Click image for larger version. 

Name:	Capture2.JPG 
Views:	11 
Size:	51.8 KB 
ID:	9456

  5. #5
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I misunderstood your question. Sorry. You are interested in data that falls in the previous two week Numbers - right?

    Quite often - when I need to run reports/queries for a particular two-week period, I schedule them to run first thing in the morning [before I get to work] before any new transactions have been entered for the next two-week period. That is the logic I was using above - sorry.
    In that case, the above logic would work.

    However, with the '>', I believe it will give you everything that has a date 'greater than' the cutoff date.

    I will see if I can figure out how to isolate the previous two week numbers and retrieve data for that range.

  6. #6
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Try this:

    In the Criteria line use between (Year(Date())*53 + DatePart("ww", Date()) - 2) and (Year(Date())*53 + DatePart("ww", Date()) - 1)

  7. #7
    tony30 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    13
    It is working nicely!! I don't get the logic of this particular expression,however the results are what I expect
    Thank you so much!!
    Tony

  8. #8
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    The best explanation I can come up with is your original query uses the = sign so you got the records for the previous week. Your query for the 2 prior weeks uses the > sign so you got everything up to today. that's why you needed the between you needed to exclude the current week.

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

Similar Threads

  1. Creating a query to display a weeks records
    By shabbaranks in forum Queries
    Replies: 16
    Last Post: 01-05-2012, 09:27 AM
  2. Help with most recent 2 weeks query.
    By tplee in forum Queries
    Replies: 7
    Last Post: 11-30-2011, 08:05 PM
  3. Replies: 3
    Last Post: 11-22-2011, 11:06 AM
  4. Using an update query, but updating +2 weeks...
    By AudiA4_20T in forum Queries
    Replies: 2
    Last Post: 08-02-2011, 07:12 AM
  5. Can't Find Subform Events
    By vdanelia in forum Forms
    Replies: 4
    Last Post: 02-28-2011, 02:23 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