2 Replies Latest reply on Mar 29, 2010 11:36 AM by Nerico_1

    Doing a find based on a date calculation

    Nerico_1

      Title

      Doing a find based on a date calculation

      Post

       

      Hi,

      I'm working on a db that manages interview dates.  We interview on Mondays and Fridays and I'm looking to create a script so I can click a button and do a find for the next interview date and another script/button for the last interview date, both based on the current date.  Are there functions to help me find the next or last date or would I have to do some sort of incremental script from scratch?

       

      I'm using FM Pro 11 on Mac OS X.

       

      thanks.

        • 1. Re: Doing a find based on a date calculation
          philmodjunk

          I would find records and then sort the results so that the next or last interview date sorts to the top of the found set. That approach will work even if unusual circumstances require an interview on a day other than Monday or Friday.

           

          Here's a script for finding the Previous Interview Date:

           

          Enter Find Mode[]

          Set field [YourTable::InterviewDate ; "< " & Get ( CurrentDate ) ]

          Set Error Capture [on]

          Perform Find []

          Sort Records [no dialog; Restore] //Sort your records in Descending order based on InterviewDate

          Go To record [first]

           

          A similar script will find the next interview date, but use > as your operator and sort your records in ascending order.

          IF you need to, once you've found and sorted these records, you can use the data in the first record to perform a second find that constrains your found set to just records with that interview date.

          • 2. Re: Doing a find based on a date calculation
            Nerico_1

            THANKS!  Looks so simple in retrospect.  I will try it and report back.