Jump to content

Function with a loop, please help

This topic is 2607 days old. Please don't post here. Open a new topic instead.

Recommended Posts



im still a bit of a beginner with filemaker


i have been trying to figure this out but need a little help. 


I have this function


(GetAsDate ( Date1) - GetAsDate (  Date2 )  <  0 ;
 Date1 + 28 ;



What i need is to turn it in to a loop


so that 28 is added to Date1 until Date1 is higher than Date2


I have tries and testes let function and loop,


if any one could help 


Many Thanks





Link to comment
Share on other sites

1. Filemaker calculations do not loop.


2. Since you have the Advanced version, you can write a custom function. A custom function can be recursive (i.e. it can call itself in a loop).


3. Looping is not required to solve the current problem. Try =

Let ( [
diff = Date2 - Date1 ;
periods = Ceiling ( diff / 28  )
] ;
Date1 + Case ( diff > 0 ; 28 * periods )

or, if you prefer =

Date1 + Max ( 28 * Ceiling ( ( Date2 - Date1 )  / 28  ) ; 0 )
  • Like 2
Link to comment
Share on other sites

This topic is 2607 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By wfcperrine12
      I have searched the web for a Custom Function that solves this to no avail…  There are many CF’s that “almost” do what I need but nothing as explained below.
      Calculate a DATE x days AFTER a given date skipping weekends AND bank holidays.
      Result Desired = Date that skips weekends and bank holidays.
      Any year’s HOLIDAY dates can be gleaned from pre-existing Custom Function “HolidayListByYear (yearNumber)” written by Jonathan Mickelson at www.briandunning.com (also uses another Custom Function he wrote called “DateByDayOccur”).
      Banking holidays should always include:
      * When a holiday falls on a Saturday, it is usually observed on the preceding Friday. When the holiday falls on a Sunday, it is usually observed on the following Monday.
      New Years Day
      Jan 1
      Martin Luther King Day
      Jan 20
      President’s Day
      Feb 17
      Memorial Day
      May 25
      Independence Day
      July 4
      Independence Day (observed)
      Labor Day
      First Monday in September
      Columbus Day
      Second Monday in October
      Veterans Day
      Nov 11
      Thanksgiving Day
      4th Thursday in November
      Christmas Eve
      December 24
      Christmas Day
      December 25
      New Year’s Eve
      December 31
      StartDate = 12/30/2020
      NumbOfDays = 2
      Result would be= 1/3/2021
      NOTE: Must skip Dec 31 (New Years Eve/weekend day), Jan 1 (New Years Day/weekend day)
      StartDate = 1/15/2021
      NumbOfDays = 2
      Result would be= 1/20/2021
      NOTE: Must skip weekend AND Jan 18, MLK Day
      StartDate = 7/2/2021
      NumbOfDays = 2
      Result would be= 7/7/2021
      NOTE: Must skip weekend and July 5 (July 5th is the observed day for Sunday, July 4, 2021)
      SPECIAL NOTE:  The custom function must be able to handle year crossovers such as EXAMPLE 1 above (going from 2020 into 2021.)
    • By Rich
      Greets, and a happy, holiday season to all.
      This is one of those "Well, I could swear it _used_ to work..." FMP (PC) problems: I want a script to create a custom-named folder on the desktop (PC) [for exporting data purposes] so I used the following (see attached) Send Event command: 
      "cmd /c md " & Quote ( Right ( Get ( DesktopPath ) ; Length ( Get ( DesktopPath ) ) -1 ) & "Job Chop-Chop! Backup" )
      ...in earlier versions of FMP--and if memory serves--it used to work. (See https://fmrift.wordpress.com/2010/02/03/creating-a-folder-from-filemaker-windows/ ). However, when I try to run the script in FMP v17.x the script fails with the following error message in the Script Debugger, "[3] Command is unavailable (for example, wrong operating system or mode)".
      So, I'm trying to figure out why the command's failing--could it possibly be it's because I'm using FMP (PC) in VMWare's Fusion PC emulator (v10.1.4, running in OS Mojave) instead of on a "real" PC? Any ideas for a tweak/fix?

    • By NewBoard
      I am attempting to use the following script in a Database:
      Set Variable [$supplierCount; Value: ValueCount ( List ( Suppliers::UUID ) )] Set Variable [$month; Value: MonthName ( Get ( CurrentDate ) )] Set Variable [$suppliers; Value: List ( Suppliers::UUID )] Loop Set Variable [$i; Value: $i+1] Exit Loop If [$i > $supplierCount] New Record/Request Set Field [Month::Month; $month] Set Field [Month::fk_Supplier; GetValue ($suppliers ; $i )] End Loop  
      When I run it, however, it creates zero New Records within my "Month" database.
      I'm not sure what the issue is. My only hunch is that the List function isn't properly creating a List of the "Suppliers::UUID" field, and is causing the ValueCount taken of it to return 0.
      Please let me know of any additional information I can provide, and thank you in advance for any assistance you can offer!
    • By naio
      My solution is build according to the 'separation model', so I would like to keep control of the local file containing the layout and presentation of the data hosted in the server.
      I wonder if I could have a script to control wether the local file gets its structure, layout or scripting modified, so I need a function to control when a change to the file has been made before giving it a version number. When the file gets open only to work with the hosted data it's not a new version.
    • By jrich4411
      Good evening people.  As the title states, I am a complete newbie to FileMaker Pro.  I've done some fairly extensive work with Excel, but this is my first experience with databases.
      For now, I'm looking for advice and suggestions.  I promise I will have plenty of "how do I... " questions later, but for now I need to pick a direction to go in with my new project.  I've spent a bunch of hours viewing Intro to FileMaker tutorials on YouTube and I've experimented with creating a couple test databases.  If this is not the correct forum for this question, please let me know.
      So, my wife and daughter are heavily involved with riding horses.  I've been drafted into being on the Board of Directors for our state Quarter Horse Association (Quarter Horse is a breed like Thoroughbred or Clydesdale).   The first thing I discovered is that they have NO association membership database of any sort.   What they do have is simply a file folder of applications for members, one folder for each year.  Me being an I.T. geek by trade, I know there is a better way.  I've at least entered the info into a spreadsheet (my specialty) so we have the info electronically to be able to reference current membership status during our shows.
      I wish to create a database for the membership, which I've done so far.  It has basic info - name, address, etc.  I have an ID field that automatically increments with each record - seems to be a strong recommendation in the tutorials I watched.  I have a field that combines the first & last name fields which I plan on using for looking up membership info, sending renewals, etc later.  I also have a membership year field and here comes my first question.  When I renew a member for the new year, I want to keep the previous year's record in the database - should I ever want to print a report for 2016 membership in 2019 for instance, I can.  So I figure I need a static member ID field that is separate from the record ID field I already have that can be linked to another database which will hold that member's horse information.   Is it possible to have a field that will increment serially when I add a new member but will copy from the previous year's info when I renew a member for a new year?  
      I'm looking for any and all suggestions - links to videos that might help - suggestions for a better way of accomplishing my goal, anything at all.   I'm not a programmer so I don't have that background FYI.
  • Who Viewed the Topic

    1 member has viewed this topic:
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.