![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
On Fri, 08 Jul 2005 10:25:34 -0400, Lawrence Leichtman wrote: I want to display the exact age of my patients in months using a calculation field. The discusssion of calculation for age in years goes back a long way but anyone know a way to get it to display the exact fraction of a year or the age in months? What IS the exact age in months? Is a month 28, 29, 30 or 31 days? Is it 30.43 days? However, I guess your question is let( now = get(currentDate); years = year(now) - year (birthday); last months = month(now) first months = month(birthday); years * 12 + last months - first months ) Now the question is how you want to deal with the very first month and the days of the current month. Maybe you want to check whether day(now) is below day(birthday) and subtract this from the total. You got the idea? Otherwise please provide some example numbers what you do expect as result. - Martin |
#3
| |||
| |||
|
|
On Fri, 08 Jul 2005 14:48:11 -0400, Lawrence Leichtman wrote: Good point about what is a month. I guess it will have to be 30.4 days as there is no good way to do it otherwise. |
|
The reason is that developmental testing results need to be based on age in months. I guess it does not have to be exactly on. |
|
Then the result is easy: (now - birthday) / 30.4 |
#4
| |||
| |||
|
|
In article <slrndd0emd.5ca.t-use (AT) ID-685 (DOT) user.individual.de>, t- use (AT) gmx (DOT) net says... On Fri, 08 Jul 2005 14:48:11 -0400, Lawrence Leichtman wrote: Good point about what is a month. I guess it will have to be 30.4 days as there is no good way to do it otherwise. Yes there is. Do it the way any reasonable human being would do it if they had to do it manually: by adding 1 month for each monthly anniversary that is reached. The reason is that developmental testing results need to be based on age in months. I guess it does not have to be exactly on. It probably doesn't have to be, but why settle for less? Then the result is easy: (now - birthday) / 30.4 I'd be much happier with Martin's earlier suggestion finished off: Let( [birthday = datex; now = datex Copy; years = Year(now) - Year (birthday); last months = Month(now); first months = Month(birthday); threshold = Day(birthday)<=Day(now)]; years * 12 + last months - first months + threshold -1) (It needs to be tested, but I think it should work right.) No one should be satisfied that a child born 2/10/2005 is still listed at being only 2 months old on 5/11/2005. Stuff like that seriously undermines faith in the validity of the software, even if its technically 'accurate enough'. Were I a tester not in the 'know' looking at that result I'd report it as a major bug. -regards, Dave |
#5
| |||
| |||
|
|
[birthday = datex; now = datex Copy; |
#6
| |||
| |||
|
|
I want to display the exact age of my patients in months using a calculation field. The discusssion of calculation for age in years goes back a long way but anyone know a way to get it to display the exact fraction of a year or the age in months? |
#7
| |||
| |||
|
|
On 7/8/05 7:25 AM, in article larry-DBD9EC.10253408072005 (AT) new...) east.cox.net, "Lawrence Leichtman" <larry (AT) lleichtman (DOT) org> wrote: I want to display the exact age of my patients in months using a calculation field. The discusssion of calculation for age in years goes back a long way but anyone know a way to get it to display the exact fraction of a year or the age in months? My hosital keeps ages in years.months format, so 6 years 11 months is 6.11, and 6 years 2 months is 6.02 . This is the calculation I use, and then format the field to 2 decimals. It makes no assumptions as to the average length of a month - it gets it right based on the calendar. Don't recall where I got this from. Year(Get(CurrentDate)) - Year(Birth date) - If(GetAsNumber(Get(CurrentDate))< Date(Month(Birth date); Day(Birth date); Year(Get(CurrentDate)));1;0)&"."& ..01*Mod(Month(Get(CurrentDate)) - Month(Birth date) + 12 - If(Day(Get(CurrentDate)) < Day(Birth date);1;0); 12) |
#8
| |||
| |||
|
|
"" wrote: On 7/8/05 7:25 AM, in article larry-DBD9EC.10253408072005 (AT) new...) east.cox.net, "Lawrence Leichtman" <larry (AT) lleichtman (DOT) org> wrote: I want to display the exact age of my patients in months using a calculation field. The discusssion of calculation for age in years goes back a long way but anyone know a way to get it to display the exact fraction of a year or the age in months? My hosital keeps ages in years.months format, so 6 years 11 months is 6.11, and 6 years 2 months is 6.02 . This is the calculation I use, and then format the field to 2 decimals. It makes no assumptions as to the average length of a month - it gets it right based on the calendar. Don't recall where I got this from. Year(Get(CurrentDate)) - Year(Birth date) - If(GetAsNumber(Get(CurrentDate))< Date(Month(Birth date); Day(Birth date); Year(Get(CurrentDate)));1;0)&"."& ..01*Mod(Month(Get(CurrentDate)) - Month(Birth date) + 12 - If(Day(Get(CurrentDate)) < Day(Birth date);1;0); 12) This works, where Now and DOB are both date fields. Case ( Month ( Now ) - Month ( DOB ) >= 0 ; Month ( Now ) - Month ( DOB ) + ( Year ( Now ) - Year ( DOB ) ) * 12 ; 12 - ( Month ( DOB ) - Month ( Now ) ) + ( Year ( Now ) - Year ( DOB ) - 1 ) * 12 ) |
![]() |
| Thread Tools | |
| Display Modes | |
| |