Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2013
    Posts
    1

    Exclamation Unanswered: Access 2010 - Contains Previous Date

    Hi all,

    Good day.

    I need help in the queries where I need it to filter for me the previous date. Let say my data contains date from 20th June, 21st June and 24th June, which mean 22nd and 23rd don't have data. I want it automatically filter the previous date which mean today is 24th June and it will filter 21st June data. I had tried Date()-1, but it only filter yesterday data which is invalid since there is no data on 23rd June. Anyone can help?

    Thanks.
    Last edited by alwinz; 06-25-13 at 00:29.

  2. #2
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    Code:
    SELECT
         DataField
    ,    AnotherDataField
    ,    YetMoreData
    ,    MAX(DateField)
    FROM
         YourTableNameHere
    WHERE
         DateField < Date()
    GROUP  BY
         DataField
    ,    AnotherDataField
    ,    YetMoreData
    Should be close to what you need.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    is the weekend significant?
    if so use the WEEKDAY function to determine how to build your filter

    is the date form significant (ie if its based on 'today' and you only want the last 3 rows AND there is only one row per day then use the TOP function
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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