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.

Scripting date range find

Featured Replies

Hello,

I would like to script a find to find all records for a month. I understand that searching for 1/1/2003...1/31/2003 will find all records for January 2003. But is there an elegant way of doing this? I only need to build reports for each month from last year and this year. I could do this with 24 scripts but there has to be a better way. Any suggestions or ideas would begreatly appreciated.

P.S. Happy New Year Everyone!!!

Michael

Why don't you use a calculation of Month( Date ) & "_" & NumToText( Year( Date ) )? You can then sort and summarize by it.

  • Author

Queue,

I should have known you would have a calc that would make this easier wink.gif. How do you deal with capturing the start and end date for the report?

Thanks, Michael

The end of the month is the day before the first of the next month. So, you could have the user enter the month and year into two global fields (gMonth and gYear) and use them in a calculation

DateToText(Date(gMonth,1, gYear) & "..." & DateToText(Date(gMonth + 1, 1, gYear) - 1)

Here the user enters the *number* of the month (1 to 12). A nicer interface can be made whereby they select the month name, however this will require another calculation to conver the monthname into the month number.

The script will need to change to a layout with the date field on it, and use the Insert Calculated Result step to enter the date search string calculation.

Do you mean for the first and last day of each month?

You can use a text calculation: DateToText( Date( Month( date ), 1, Year( date ) ) ) & "..." & DateToText( Date( Month( date ) + 1, 1, Year( date ) ) - 1 ) and put this on the header or subsummary part.

Cool, Queue... the same calculation used for two different purposes!

I guess that means we know we got it right. Kind of like 'checking your work' in high school. cool.gif

Hi Vaughan,

I am seeking a way to find all the months represented between & including the Start Date and End Date. For example, if a project starts in January and is to finish in March, what calculation would I need to write so a find picks up the project to appear in discreet reports for January, February and March. Can't work out how to get it to recognise February. Hope this makes sense. Thanks for any suggestions.

Cathy

  • Author

Thanks Queue and Vaughn! Your suggestions sent me in the right direction. grin.gif

Have you tried Insert Calculated Result ["date field", "DateToText( gStartDate ) & "..." & DateToText( gEndDate )"]?

The bold quotes are ones that FileMaker will automatically enter, so you won't need to. I show it this way because this is how it will look in ScriptMaker.

"what calculation would I need to write so a find picks up the project to appear in discreet reports for January, February and March"

Have you tried a summary report, using a "month" field as the break?

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.