Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Posts
    24

    Unanswered: querying a week?

    ok i need to produce a query on a table. in that table contants a comllum with a number of different dates. i need that query to show all the records that hold the date that appeared in the monday - sun that happen in the last week e.g. say i ran the query on a wednesday it would give me all the record with a date in the mon - sun before. how would i achieve this? i think this is possable im just not familer with access myself???

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    I just used one of my own table for an example, of course you need to put in your own table and field names:

    Code:
    SELECT dbo_PRDCTN_ERRORLOG.*
    FROM dbo_PRDCTN_ERRORLOG
    WHERE (((DatePart("ww",[ErrDate]))=DatePart("ww",DateAdd("d",-7,Now()))) AND ((Year([ErrDate]))=Year(DateAdd("d",7,Now()))));

    My formula assumes SUNDAY is the first day of the week. If you need to use Monday as the first day, you'll have to add some more "DATEPART" & "DATEADD" to it.
    Inspiration Through Fermentation

  3. #3
    Join Date
    Jun 2008
    Posts
    24
    thank you, this seem to solve the problem the only problem being as far as i can see is that i have no idea what to do with that line of code....

    i haven't really gone into VBA as far as Access to be honest i have done anything with it, so could i have some more help????

  4. #4
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    This isn't VBA. Just open query analyzer, go to the SQL view instead of regular design view. Paste my SQL in there and change "dbo_Prdctn_ErrorLog"
    to your table name, and change [ErrDate] in the Where clause to your date field name. Then switch back to design view and it should look familiar to you again.
    Inspiration Through Fermentation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •