Re: Find in a date range



In article
<62bbe55f-fc4f-46aa-a539-32c493bf403f@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
buck.matthew74@xxxxxxxxx wrote:

FM 8.5

I want to create a script that will select all records in the past
week, past month, this year.
Please help.

Thank you
Matthew

You'll need three Scripts, but they all should be the same as how you
would perform the Find manually ... with a slight hitch that FileMaker
is a little picky about date formats.

Manually to find the "past week" records you would:

- Enter Find mode

- Go to the date field and type in the date 7 days ago
followed by the date range symbol (ie. "...") and
then "today's" date

- Finally perform the Find

The equivalent Script would then be something like:

Enter Find Mode []
Set Field [DateField,
GetAsText(Get(CurrentDate) - 7) & "..."
& GetAsText(Get(CurrentDate))]
Perform Find []

(Note: Due to a bug in FileMaker, you may need to swap Set Field to
another function in some versions of FileMaker, eg. Insert Calculated
Result in the older versions)


For the "past month" and "this year" are slightly more compliced
because you have to play around with the Date functions of Date, Month,
Day and Year, but the basic idea is the same.

For "past month" you have to subtract a "month" from "today's" date ...
but it really depends whether you mean an actual calendar month (eg. 15
October to 15 November) which may vary in the number of days / weeks or
a simpler "4 week" month.

Assuming you mean a calendar month the calculation part of the Set
Field above has to work out the current month and subtract 1. To do
this it needs to pull apart the date into ots separate day, month and
year parts using the appropriate functions, subtract the 1 month, and
then put the parts back together into a date using the Date function.
eg.
GetAsText(
Date(
Month(Get(CurrentDate) - 1), Day(Get(CurrentDate)),
Year(Get(CurrentDate))
)
)
& "..." & GetAsText(Get(CurrentDate))


It's a similar calculation for the "past year", except you are
subtracting 1 from the year instead of the month.

Thankfully you don't have to worry about changeovers from one year to
the previous one (eg. December 2007 ... January 2008) since FileMaker's
date functions will handle this itself.


Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)
.



Relevant Pages

  • Re: Help choosing a field from a script
    ... calculation. ... Also, is there a way to have FMP choose the fields itself, or do I ... the next script is Set Field without specifying the field name. ...
    (comp.databases.filemaker)
  • Re: Find in a date range
    ... The equivalent Script would then be something like: ... Assuming you mean a calendar month the calculation part of the Set ... Field above has to work out the current month and subtract 1. ... Captain) instead of a year month day or day month year format. ...
    (comp.databases.filemaker)
  • Re: Set Field doesnt accept parameters
    ... And, by the way, Set Field does not work at all. ... parameter, whether in an If loop, or subscript or calculation. ... so you can use one script to be run from six different buttons. ... > getin the script to branch off to different layouts, ...
    (comp.databases.filemaker)
  • Re: automatic field creation
    ... I would avoid using Tabs, but there are so many fields in the Echo ... 40 calculated fields could slow down a solution depending on how many related fields they refer to or what the calculation is. ... I would put the calculation directly in the Specify dialog of the Set Field. ... and that script step requires that the field be on the layout. ...
    (comp.databases.filemaker)
  • Re: Creating server based image catalogs with Filemaker?
    ... I send incoming pics through a batchrename (also a filemaker ... I did not send you a script, but some calculation examples. ... Currently it holds over 15,000 images, and more are added ...
    (comp.databases.filemaker)