1 Reply Latest reply on Feb 8, 2013 9:03 AM by philmodjunk

    Searching a date range with variables

    Matty_1

      Title

      Searching a date range with variables

      Post

           I'm currently trying to search a date range with two variables.

           I have a global field where I select the monday of whichever week I wish to view.  I then have a trigger in that global field on object save that launches a script that first establishes the first day requested in the search by taking the day selected in the global field with a  set variable script step.  I then have a second variable which takes the date in the field and adds 4 days to establish a monday to friday range.  This all works.

           The hitch is in the perform find step.  I've put "$Date...$DateEnd" and for some reason this is returning exactly what I have in quotations instead of the dates established by the set variable steps.  I know that the set variable steps work properly because of the data viewer and I've modified the perform find step to search for "$Date" and "$DateEnd" on their own both work properly.

           This all stops when I try to combine both.  What am I missing?!

        • 1. Re: Searching a date range with variables
          philmodjunk

               If you are entering the initial data in a global field you don't need any variables.

               You can use this kind of code:

               Enter find Mode []
               Set Field [YOurTable::DateField ; YourTable::GlobalMonday & "..." & YourTable::GlobalMonday + 4 ]
               Set Error Capture [on]
               Perform Find[]

               What you are trying now, within a stored find request doesn't work because Filemaker can't evaluate a calculation within a stored find request. You could use:

               Set Variable [$DateRange ; value: YourTable::GlobalMonday & "..." & YourTable::GlobalMonday + 4 ]

               and then you have a single variable you can use in a stored find request, but I prefer the first method I posted as it enables me to see all the criteria used in the find without the added inconvenience of double clicking a script step to open up an extra dialog to see what was specified.

               For more scripted find examples using the first method, see: Scripted Find Examples