![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
On Mon, 18 Jul 2005 13:45:15 GMT, Amanda Robin wrote: Hi all, I have an age calculation field. I use the calculation: Year(Get ( CurrentDate )) - Year(Birthdate) - (Month(Get ( CurrentDate )) < Month(Birthdate)) - ((Month(Get ( CurrentDate )) = Month(Birthdate)) and (Day(Get ( CurrentDate )) < Day(Birthdate))) (thanks to Glenn Schwandt). So every morning when I open the database (I use FMP server 7) it takes a few minutes to calculate for the 11,000 or so records. The problem is that since I have migrated to FMP 7, this calculation changes the modification date of every record every day, defeating the purpose of having a modification date field. How does one calculate an age every day without modifying every record? My only idea is to populate the age field one time with a calculation such as the above, then have it be a plain old (uncalculated) number field. Then have a script on opening the database that searches for records whose DOB has the day and month of any days that have passed since the last opening of the database, then calculate the age for only those records. Feels klunky. I'm sure there are better methods out there. Anyone? As soon as you NEED the result, you should recalculate it. However, I wonder whether you really want to compute the age. You application looks more like some kind of birthday search!? |
|
Create a stored field 'birthday' as e.g. right("00", month(birthday),2) & right("00", day(birthday),2) Use a startup script that will search on a matching range of birthdays, e.g. from 0718 til 0801: enter find mode set field (birthday), right("00", month(get(CurrentDate)),2) & right("00", day(get(CurrentDate)),2) & "..." & right("00", month(get(CurrentDate)+14),2) & right("00", day(get(CurrentDate)+14),2) ) perform find IS this what you look for? |
|
Then you might improve this solution e.g. to work correctly on dates which pass the years border. Otherwise you might use e.g. an age value for days until end of year and keep a global field for this reference day. An easy option might be not to use a calculation field, but a plain field where you limit the number of records in question to a certain subset and do a replace-operation on those records only. HTH, Martin |
#3
| |||
| |||
|
|
In article <slrnddnes9.35f.t-use (AT) ID-685 (DOT) user.individual.de>, Martin Trautmann <t-use (AT) gmx (DOT) net> wrote: On Mon, 18 Jul 2005 13:45:15 GMT, Amanda Robin wrote: Hi all, I have an age calculation field. I use the calculation: Year(Get ( CurrentDate )) - Year(Birthdate) - (Month(Get ( CurrentDate )) < Month(Birthdate)) - ((Month(Get ( CurrentDate )) = Month(Birthdate)) and (Day(Get ( CurrentDate )) < Day(Birthdate))) (thanks to Glenn Schwandt). So every morning when I open the database (I use FMP server 7) it takes a few minutes to calculate for the 11,000 or so records. The problem is that since I have migrated to FMP 7, this calculation changes the modification date of every record every day, defeating the purpose of having a modification date field. How does one calculate an age every day without modifying every record? My only idea is to populate the age field one time with a calculation such as the above, then have it be a plain old (uncalculated) number field. Then have a script on opening the database that searches for records whose DOB has the day and month of any days that have passed since the last opening of the database, then calculate the age for only those records. Feels klunky. I'm sure there are better methods out there. Anyone? As soon as you NEED the result, you should recalculate it. However, I wonder whether you really want to compute the age. You application looks more like some kind of birthday search!? We need the age. This is for a social services program that helps people find medical services. We need to have the exact integer age in years for every client, every day. They become eligible for things as they turn 19, 40, 65, etc. Create a stored field 'birthday' as e.g. right("00", month(birthday),2) & right("00", day(birthday),2) Use a startup script that will search on a matching range of birthdays, e.g. from 0718 til 0801: enter find mode set field (birthday), right("00", month(get(CurrentDate)),2) & right("00", day(get(CurrentDate)),2) & "..." & right("00", month(get(CurrentDate)+14),2) & right("00", day(get(CurrentDate)+14),2) ) perform find IS this what you look for? It's close. I'm thinking about it. Then you might improve this solution e.g. to work correctly on dates which pass the years border. Otherwise you might use e.g. an age value for days until end of year and keep a global field for this reference day. An easy option might be not to use a calculation field, but a plain field where you limit the number of records in question to a certain subset and do a replace-operation on those records only. HTH, Martin Thank you for these ideas. I like the stored field for the month and day. I'm still unsure how to handle the range to check. We open the database virtually every weekday, except for a short vacation in November and a longer one in December. I need a balance between not taking too wide of a range, but obviously _never_ skipping a date. |
#4
| |||
| |||
|
|
In article <amanderr-8FA513.13020618072005 (AT) news (DOT) dallas.sbcglobal.net>, Amanda Robin <amanderr (AT) yahoo (DOT) com> wrote: In article <slrnddnes9.35f.t-use (AT) ID-685 (DOT) user.individual.de>, Martin Trautmann <t-use (AT) gmx (DOT) net> wrote: On Mon, 18 Jul 2005 13:45:15 GMT, Amanda Robin wrote: Hi all, I have an age calculation field. I use the calculation: Year(Get ( CurrentDate )) - Year(Birthdate) - (Month(Get ( CurrentDate )) < Month(Birthdate)) - ((Month(Get ( CurrentDate )) = Month(Birthdate)) and (Day(Get ( CurrentDate )) < Day(Birthdate))) (thanks to Glenn Schwandt). So every morning when I open the database (I use FMP server 7) it takes a few minutes to calculate for the 11,000 or so records. The problem is that since I have migrated to FMP 7, this calculation changes the modification date of every record every day, defeating the purpose of having a modification date field. How does one calculate an age every day without modifying every record? My only idea is to populate the age field one time with a calculation such as the above, then have it be a plain old (uncalculated) number field. Then have a script on opening the database that searches for records whose DOB has the day and month of any days that have passed since the last opening of the database, then calculate the age for only those records. Feels klunky. I'm sure there are better methods out there. Anyone? As soon as you NEED the result, you should recalculate it. However, I wonder whether you really want to compute the age. You application looks more like some kind of birthday search!? We need the age. This is for a social services program that helps people find medical services. We need to have the exact integer age in years for every client, every day. They become eligible for things as they turn 19, 40, 65, etc. Create a stored field 'birthday' as e.g. right("00", month(birthday),2) & right("00", day(birthday),2) Use a startup script that will search on a matching range of birthdays, e.g. from 0718 til 0801: enter find mode set field (birthday), right("00", month(get(CurrentDate)),2) & right("00", day(get(CurrentDate)),2) & "..." & right("00", month(get(CurrentDate)+14),2) & right("00", day(get(CurrentDate)+14),2) ) perform find IS this what you look for? It's close. I'm thinking about it. Then you might improve this solution e.g. to work correctly on dates which pass the years border. Otherwise you might use e.g. an age value for days until end of year and keep a global field for this reference day. An easy option might be not to use a calculation field, but a plain field where you limit the number of records in question to a certain subset and do a replace-operation on those records only. HTH, Martin Thank you for these ideas. I like the stored field for the month and day. I'm still unsure how to handle the range to check. We open the database virtually every weekday, except for a short vacation in November and a longer one in December. I need a balance between not taking too wide of a range, but obviously _never_ skipping a date. Here's the age calculation I use (FMP6). If(IsEmpty(BirthDate),"",(Year(Today) - Year(BirthDate)) - If(DayofYear(Today) >= DayofYear(BirthDate), 0, 1)) Not having used FMP7 I can't help you with the modification date problem. Is it maybe an issue of whether or not the calculation result is stored? |
#5
| |||
| |||
|
|
In article <uce-F1F049.17283718072005 (AT) comcast (DOT) dca.giganews.com>, uce (AT) splook (DOT) com says... Here's the age calculation I use (FMP6). If(IsEmpty(BirthDate),"",(Year(Today) - Year(BirthDate)) - If(DayofYear(Today) >= DayofYear(BirthDate), 0, 1)) Not having used FMP7 I can't help you with the modification date problem. Is it maybe an issue of whether or not the calculation result is stored? Probably, but unstoring it is totally worthless if he wants to search on it. |
#6
| |||
| |||
|
|
In article <MPG.1d45c4283951b9e7989c06 (AT) shawnews (DOT) vf.shawcable.net>, 42 <nospam (AT) nospam (DOT) com> wrote: In article <uce-F1F049.17283718072005 (AT) comcast (DOT) dca.giganews.com>, uce (AT) splook (DOT) com says... Here's the age calculation I use (FMP6). If(IsEmpty(BirthDate),"",(Year(Today) - Year(BirthDate)) - If(DayofYear(Today) >= DayofYear(BirthDate), 0, 1)) Not having used FMP7 I can't help you with the modification date problem. Is it maybe an issue of whether or not the calculation result is stored? Probably, but unstoring it is totally worthless if he wants to search on it. Um. No, actually it's not. Searching works fine here with a non-stored calculation. That's even fairly well implied by the phrasing within the Calculation Options window. |
|
From the task described, I'm not sure if search is an important function anyway, so even the modest speed hit may not be a real problem. |

#7
| |||
| |||
|
|
In article <slrnddnes9.35f.t-use (AT) ID-685 (DOT) user.individual.de>, Martin Trautmann <t-use (AT) gmx (DOT) net> wrote: On Mon, 18 Jul 2005 13:45:15 GMT, Amanda Robin wrote: Hi all, I have an age calculation field. I use the calculation: Year(Get ( CurrentDate )) - Year(Birthdate) - (Month(Get ( CurrentDate )) < Month(Birthdate)) - ((Month(Get ( CurrentDate )) = Month(Birthdate)) and (Day(Get ( CurrentDate )) < Day(Birthdate))) (thanks to Glenn Schwandt). So every morning when I open the database (I use FMP server 7) it takes a few minutes to calculate for the 11,000 or so records. The problem is that since I have migrated to FMP 7, this calculation changes the modification date of every record every day, defeating the purpose of having a modification date field. How does one calculate an age every day without modifying every record? My only idea is to populate the age field one time with a calculation such as the above, then have it be a plain old (uncalculated) number field. Then have a script on opening the database that searches for records whose DOB has the day and month of any days that have passed since the last opening of the database, then calculate the age for only those records. Feels klunky. I'm sure there are better methods out there. Anyone? As soon as you NEED the result, you should recalculate it. However, I wonder whether you really want to compute the age. You application looks more like some kind of birthday search!? We need the age. This is for a social services program that helps people find medical services. We need to have the exact integer age in years for every client, every day. They become eligible for things as they turn 19, 40, 65, etc. |
#8
| |||
| |||
|
|
If its not stored then it has to be calculated on the fly for a search; the result by definition can't be indexed. Sure you can brute force search several thousand records on a fast machine without it dragging you down if its a simple enough calc that does't use aggregates or related files, but its still a silly approach that can't scale well as the database grows. I say "silly" because its completely unnecessary... a different but equivalent query lets you search an indexed field. |
|
From the task described, I'm not sure if search is an important function anyway, so even the modest speed hit may not be a real problem. When you want to display the age, then an unstored calc makes perfect sense. If you want to search on an age, it makes more sense to query the indexed date field for a date range rather than an unstored calculation. |
|
If you wanted to find all the invoices that were made last week you'd search for invoices dated between x and y. You wouldn't define some calculation off the current date and then update each record each day... with how many weeks old each is and then search that. Why would the age of people be handled differently? ![]() |
#9
| |||
| |||
|
|
On Tue, 19 Jul 2005 05:47:06 -0400, Gregory Weston wrote: Yes. If. You seem to be focussed on solving a problem different from that described. And I think I see what happened. Someone else brought up the notion of a search, but that's actually, AFAICT, along a branch toward one suboptimal solution to the original problem. I guess that was me. The question was that a daily recalculation of the age takes too much time. The question did not actually explain how and why this was required. |
|
Now it's clearer - but a calculation on every record is still the wrong solution. I still don't get the real problem why you actually want to check daily when someone will pass a 19/45/x years border. |
#10
| |||
| |||
|
|
In article <slrnddpmns.48g.t-use (AT) ID-685 (DOT) user.individual.de>, Martin Trautmann <t-use (AT) gmx (DOT) net> wrote: On Tue, 19 Jul 2005 05:47:06 -0400, Gregory Weston wrote: Yes. If. You seem to be focussed on solving a problem different from that described. And I think I see what happened. Someone else brought up the notion of a search, but that's actually, AFAICT, along a branch toward one suboptimal solution to the original problem. I guess that was me. The question was that a daily recalculation of the age takes too much time. The question did not actually explain how and why this was required. I've misread, then. I thought the question was how to eliminate a behavior, newly discovered in FMP7, where the recalc was changing the modification date on the records. Now it's clearer - but a calculation on every record is still the wrong solution. I still don't get the real problem why you actually want to check daily when someone will pass a 19/45/x years border. I didn't see that as the task. I thought it was "When I'm looking at this person, I need to be able to see their current age." G |
![]() |
| Thread Tools | |
| Display Modes | |
| |