Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Hello, everyone!

This is a simple question but the answer would help me a lot:

How can I add month by month? In a Loop script I need to add the next month to the next record in a set of 30 records. I tried Date(Month((invoice_date)+ 1), Day(invoice_date), Year(invoice_date)) but it didn't work. The year also wasn't affected.

I'll appreciate if you can give me a hand.

Thanks.

Hi,

Don't know exactly what your script looks like, but try Insert Calculated result (your calc) .

  • Author

My script look like this:

Set Field ("counter", "0")

Loop

Exit Loop If ("g_counter = 30")

Set Field ("g_counter", "g_counter + 1")

New Record/Request

Set Field ("invoice_month", "????:?")

Here is where I wanto to increase the invoice_month date field month by month, starting from January 2003, and ending in June 2005 after 30 months.

I'm from Costa Rica. I hope you understand what I'm trying to say.

Thanks.

You mean you want to add 1 month to the date, right? Your formula has an error in it. The problem is with the parentheses. Change it to:

Date(Month(invoice_date)+ 1, Day(invoice_date), Year(invoice_date))

The calc should be:

TextToDate(Day(invoice_date) & "/" &

If(Month(invoice_date) = 12,

"1/" & Year(invoice_date) + 1,

Month(invoice_date) + 1 & "/" & Year(invoice_date)))

Dan, your calculation is more complex than necessary. The date function handles the rollover into a new year automatically. If the month part of the Date() function is more than 12, then it automatically adjusts the year and month to the required values.

In either method though, you need to watch out for a problem that might come up where, for example, the invoice date is January 31, and adding a month to this date has a couple of possibilities. You might want the result to be February 28, or you might want the result to be March 2 (invoice date plus 30 days).

Assuming that you want to the result to be no later than the last day of the following month, then you can use this calc:

Date(Month(InvoiceDate)+1, Min(Day(InvoiceDate),Day(Date(Month(InvoiceDate)+2,0,Year(InvoiceDate)))), Year(InvoiceDate))

Here is a script that should work:


# You will need a global date field: gStartDate

Set field [gStartDate, InvoiceDate]

Set field [gCounter, 0]

Loop

  Exit Loop if [gCounter >=30]

  Set field [gCounter, gCounter+1]

  New Record/Request

  Set field [invoice date,Date(Month(gStartDate)+gCounter, Min(Day(gStartDate),

      Day(Date(Month(gStartDate)+gCounter+1,0,Year(gStartDate)))), Year(gStartDate)) ]

End Loop

  • Author

Thanks everyone for your help. How far I was of resolving my problem for myself! I'm not an expert in FileMaker to pay you back, but when you come to Costa Rica, I promise to get the best discounts for you in hotels, tour an transportation.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.