Results 1 to 2 of 2
  1. #1
    Join Date
    May 2006

    Unanswered: Last Date in Criteria


    I have a table with transactions that have dates going back years. I am trying to query using the last transaction date in the table and go back 30 days from it and pull the data. I know that >Days()-30 pulls the last 30 days from today's date. However, I do not need the last 30 days of data from today's date, but from the last transaction date in the table. Is there a way to enter in the criteria to do this? I know you can manually enter in the last date, but I have multiple queries showing different date parameters (last 30, 60, 90 days and so on) and do not want to manually change the last date in the criteria. This is probably a newbie question, but I'm just stumped. Thanks.

  2. #2
    Join Date
    Dec 2002
    Préverenges, Switzerland
    DMax("yourDateField", "YourTable")
    gives you the max date.

    given that Dxxxx() is criticised for being slow, if you plan to run queries on the same client for -30, -60, -90 for a given DMax it might be worth saving the return in a var for the subsequent queries.
    one-off: it's not worth it.

    then you 'cheat' with your Dmax("yourDateField", "YourTable") - 30
    of you use the officially sanctioned dateadd()
    they both work tho

    currently using SS 2008R2

Posting Permissions

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