Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

  • Newbies
Posted

I am trying to create an array of dates that are a week apart and list for x weeks. So if a starting date is 4/25/2010, and x = 4, I would end up with:

4/25/2010

5/2/2010

5/9/2010

5/16/2010

Struggling with how to do this.. any insights would be most welcome.. TIA

Posted

Hi there! Welcome to FM Forums! :laugh2:

You can use a global field (call it gStartDate) to input the start date. You would use another global field (call it gNumWeeks) to input the number of records (weeks). Then script could be:

Loop

Exit Loop If [ $num > gNumWeeks ]

New Record/Request

Set Field [ yourDateField ; gStartDate + $num * 7 ]

Set Variable [ $num ; $num + 1 ]

End Loop

... as always, back up before trying something new in your file.

  • Newbies
Posted

I'm using this for the left side of a relationship. So, while I could script the process, that seems to carry a lot of overhead. A calculation seems more in line with what I want to do. Any thoughts on how to structure a calculation to do this?

Posted

Then if you don't need new records, it doesn't have to be scripted.

Let (

i = Get ( CalculationRepetitionNumber ) ;

Extend ( gStartDate ) + 7 * i

)

Posted

Try:


Let ( [

i = Get ( CalculationRepetitionNumber )

] ;

Case ( i ≤ Extend ( x ) ; Extend ( StartDate ) + 7 * ( i - 1 ) )

)

Give the field enough repetitions to cover the worst case scenario.

Posted

I was just going to modify so it stopped according to a specified number of weeks. And I was also going to add that I got this calculation originally from you. In fact, it's on my wall because it's so pretty. :wink2:

  • Newbies
Posted

Can you explain how I should implement this a little more. I created a calculation field with 16 repetitions which references a startdate field, but it does not give me the result I need. I also noticed that where you have:

i ≤ Extend ( x )

If I try to use a number rather than x, FileMaker tells me that I need to reference a field rather than use an expression.

Posted (edited)

"but it does not give me the result I need. "

What result does it give you? Did you go to field setup and change so the calc displays the repetitions? If the calc produces a series of numbers (similar to 73387) then the result of the calculation must be changed to date.

You should replace the x with a global field which holds the number of weekly dates you specify (such as 4). It could also be an unstored number calculation (with only the number 4 in it) but you would have to amend the calc every time you wanted to change the number.

Edited by Guest
Posted

If x is a constant rather than a variable, then you can shorten the formula to =

Extend ( StartDate ) + 7 * ( Get ( CalculationRepetitionNumber ) - 1 )

and make the number of repetitions equal to x.

This topic is 5384 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
×
×
  • Create New...

Important Information

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