Results 1 to 3 of 3
  1. #1
    Emile is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    Apr 2016
    Posts
    1

    How to get the current week -1 week and CYTD -1 year (use a CYweek in an number format).


    Dear Access wizards,

    Currently I'm using Access to store weekly data of our market.
    Every week I receive a flatfile which I integrate in Access.
    As a timekey I'm using a CYWEEK (example: 201615).

    Now the thing is, when I make a query, I want to be able to see the latest week (highest value). Therefore I used the max function and had to create a separate query. This worked fine.

    However I would also like to be able to return the values of the current week and the previous week. Which in this case, would be 201615-1 = 201614. In excel I have data connections to access so I'm able to refresh the file every week and with that update all tables and graphs. Therefore, I don't want have to fill in the criteria of the previous week, manually in access.

    This problem is the same as I want to see the current week for last year. (201615-100=201515). Does anyone know a way on how to solve this?

    I have attached an excel file which could clarify the problem a little better.

    Thanks in advance!!!

    Kind regards,
    Emile
    Attached Files Attached Files

  2. #2
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,044
    Hi,

    you can use the function dateadd(interval,number,date)
    like: fldPreviousWeek : datedadd("ww",-1, date())

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If I understand correctly, maybe a union query will work.
    The first query would return the current data, the second query would return last week data and the third query would return last years data for the current week.

    You can't use the query designer for the union query, you have to type it in.

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: 3
    Last Post: 06-22-2015, 06:36 AM
  3. Replies: 9
    Last Post: 06-19-2015, 03:37 PM
  4. Replies: 3
    Last Post: 09-19-2013, 10:18 AM
  5. Week Number of Month not Year?
    By kwooten in forum Queries
    Replies: 6
    Last Post: 05-01-2013, 06:59 AM

Tags for this Thread

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