5 Replies Latest reply on Nov 18, 2011 1:09 PM by KylePutzier

    Scripted timestamp find

    KylePutzier

      I need to find records that have a timestamp, stored in a timestamp field, that is less than the current timestamp.

       

       

      I bet the answer is in this forum some place, but I cant find it.

       

      Kyle

        • 1. Re: Scripted timestamp find
          RayCologon

          Hi Kyle,

           

          If you're using FileMaker 11, you can use a variable in a find, so the following script will do:

           

          -  Set Variable [$criteria; Value:"<" & Get(CurrentHostTimeStamp)]

          -  Perform Find [Restore]

           

          ...where the find configuration references the variable, as shown below:

           

          FindCriteria.png

           

          If you need it to work in earlier versions as well, then you'll need a slightly longer script aling the lines of:

           

          -  Enter Find Mode [ ]

          -  Set Field [YourFile::Timestamp; "<" & Get(CurrentHostTimeStamp)]

          -  Perform Find [ ]

           

          The latter method will, of course also work in v11.

           

          Regards,

          Ray

          ------------------------------------------------

          R J Cologon, Ph.D.

          FileMaker Certified Developer

          Author, FileMaker Pro 10 Bible

          NightWing Enterprises, Melbourne, Australia

          http://www.nightwingenterprises.com

          ------------------------------------------------


          • 2. Re: Scripted timestamp find
            KylePutzier

            I changed the calculated timestamp into a calce number field and changed the scripted Get(CurrentTimeStamp) into a number. Works as intended now.

            Kyle

            • 3. Re: Scripted timestamp find
              RayCologon

              KylePutzier wrote:

              I changed the calculated timestamp into a calce number field and changed the scripted Get(CurrentTimeStamp) into a number. Works as intended now.

              Kyle

               

              Hi Kyle,

               

              Not sure why you'd have been able to make it work after changing to a number format, but not while the field was in timestamp format.

               

              FWIW, attached is a demo file that shows both the scripts from my previous post, targeting a timestamp formatted field. If you have a moment to look at the demo and compare it with your file, it might help you figure out what was stopping your script from working?!

               

              Regards,

              Ray

              ------------------------------------------------

              R J Cologon, Ph.D.

              FileMaker Certified Developer

              Author, FileMaker Pro 10 Bible

              NightWing Enterprises, Melbourne, Australia

              http://www.nightwingenterprises.com

              ------------------------------------------------

              • 4. Re: Scripted timestamp find
                KylePutzier

                For some reason, it would ignore the time portion of the timestamp and only find records when the date portion was < than the CurrentTimeStamp

                I'll look at your demo and see f I can find what I did wrong.

                • 5. Re: Scripted timestamp find
                  KylePutzier

                  Don't know. Your demo works fine. I thought It might be because I didn't have seconds in my calc'd timestamp, but that doesn't matter in your demo either.