2 Replies Latest reply on Dec 12, 2015 1:31 PM by Mike_Mitchell

    How do I filter/perform save based on current month as date?

    ryanmead83

      I have scripts that activate when a button is pressed, like go to list view layout and perform find setting fields like "Sales Stage" = "Closed Won" to see won deals etc.  The problem I'm having is how to do I do it so that I can make views that say "Close Date" = "This Month" or "Last Month", "This Year" etc?  So far I have to keep editing the scripts to manually modify them such as close date between 12/1/2015 and 12/30/2015 etc which is a big pain.  I feel like I'm missing something just not sure what the operator or whatever is to just say this month?  I just want to be able to enter find mode and have "Current Month" as the search term for date, or "Last Month" etc.

        • 1. Re: How do I filter/perform save based on current month as date?
          mikebeargie

          Enter Find Mode [ no pause ]

          Set Field [ table::yourDate ; Month(get(currentdate)) & "/*/" & Year(get(currentdate)) ]

          Perform Find

          Basically you are calculating the current month, EG today is 12/12/2015 so this would return 12/*/2015. The * is a search variable allowing any value for the month.

           

          Using filemaker's date functions will allow you to set date searches dynamically. I also like the above rather than trying to throw your requests in the perform find script step because it's easier to read. In this case the perform find script step is the equivalent to the return key or pressing the "perform find" button while you are in find mode.

          • 2. Re: How do I filter/perform save based on current month as date?
            Mike_Mitchell

            Mike B's answer is correct, and may be easier to understand when you review the code later.

             

            A shortcut is simply to use:

             

                 Set Field [ table::yourDate ; Month ( Get ( CurrentDate )) ]

             

            If you put just the month in a date field when you search, FileMaker automatically assumes you want any day in that month in the current year.