Re: Find in a date range
- From: Helpful Harry <helpful_harry@xxxxxxxxxxxxxxxx>
- Date: Wed, 27 Feb 2008 18:25:43 +1300
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)
.
- Follow-Ups:
- Re: Find in a date range
- From: buck . matthew74
- Re: Find in a date range
- References:
- Find in a date range
- From: buck . matthew74
- Find in a date range
- Prev by Date: Re: Find in a date range
- Next by Date: Re: opening a file and running scripts by account
- Previous by thread: Re: Find in a date range
- Next by thread: Re: Find in a date range
- Index(es):
Relevant Pages
|
|