dbTalk Databases Forums  

Displaying age from birthdate

comp.databases.filemaker comp.databases.filemaker


Discuss Displaying age from birthdate in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rick Altman
 
Posts: n/a

Default Displaying age from birthdate - 08-01-2005 , 12:56 PM






I am attempting to create a simple display of a person's age from his or her
birthdate. I want the display to be in the form of

17y 5m

and I am running into difficulty. Here is the formula as I have devised it,
with Birthdate being a manually-entered date:



Let (Age=((Get(CurrentDate)-Birthdate)/365);
Int(Left(Age;2)) & "y " & Int(Right(Round(Age;1);1)*(12/10)) & "m")

//This long function does the following:
//1. Defines a variable that is a person's age, based on Birthdate
//2. Pulls out the first two digits as the year
//3. Pulls out the last digit and converts it from decimal to month



The conversion to y/m display fails with various dates. For instance, if you
were to enter "8/1/03", the display would return 2y 2m. If anyone knows why
this is happening, or knows of a better formula for accomplishing this task,
I would appreciate hearing from you.




Rick A.
Pleasanton, CA



Reply With Quote
  #2  
Old   
Matt Wills
 
Posts: n/a

Default Re: Displaying age from birthdate - 08-01-2005 , 02:01 PM






Rick Altman wrote:

Quote:
I am attempting to create a simple display of a person's age from his or
her birthdate. I want the display to be in the form of

17y 5m

and I am running into difficulty. Here is the formula as I have devised
it, with Birthdate being a manually-entered date:



Let (Age=((Get(CurrentDate)-Birthdate)/365);
Int(Left(Age;2)) & "y " & Int(Right(Round(Age;1);1)*(12/10)) & "m")

//This long function does the following:
//1. Defines a variable that is a person's age, based on Birthdate
//2. Pulls out the first two digits as the year
//3. Pulls out the last digit and converts it from decimal to month



The conversion to y/m display fails with various dates. For instance, if
you were to enter "8/1/03", the display would return 2y 2m. If anyone
knows why this is happening, or knows of a better formula for
accomplishing this task, I would appreciate hearing from you.




Rick A.
Pleasanton, CA
Take a look at this Custom Functon:
http://www.briandunning.com/filemake...l.php?fn_id=57.
Custom Functions are specifically a Developer thing, but there's nothing
stopping you from using a CF as a calculation.

It doesn't do precisely what you desribed, but it comes real close. You
might be able to adjust it to your needs.

Matt


Reply With Quote
  #3  
Old   
Dan
 
Posts: n/a

Default Re: Displaying age from birthdate - 08-01-2005 , 06:47 PM



Matt Wills wrote:
Quote:
Rick Altman wrote:

I am attempting to create a simple display of a person's age from
his or her birthdate. I want the display to be in the form of

17y 5m

and I am running into difficulty. Here is the formula as I have
devised it, with Birthdate being a manually-entered date:



Let (Age=((Get(CurrentDate)-Birthdate)/365);
Int(Left(Age;2)) & "y " & Int(Right(Round(Age;1);1)*(12/10)) & "m")

//This long function does the following:
//1. Defines a variable that is a person's age, based on Birthdate
//2. Pulls out the first two digits as the year
//3. Pulls out the last digit and converts it from decimal to month



The conversion to y/m display fails with various dates. For
instance, if you were to enter "8/1/03", the display would return 2y
2m. If anyone knows why this is happening, or knows of a better
formula for accomplishing this task, I would appreciate hearing from
you. Rick A.
Pleasanton, CA

Take a look at this Custom Functon:
http://www.briandunning.com/filemake...l.php?fn_id=57.
Custom Functions are specifically a Developer thing, but there's
nothing stopping you from using a CF as a calculation.

It doesn't do precisely what you desribed, but it comes real close.
You might be able to adjust it to your needs.

Matt
I have just written out a calculation based on what I would do to
calculate someone's age - I've tested in on a few dates and it seems to
work OK. I have no idea if it is related to the custom calculations. and
it works out the months and years in two seperate calculations: So using
DOB for date of Birth

AgeYears = Year(Today) - Year(DOB) + Div(12 + Month(Today) -
Month(DOB) - 1 + (Day(Today) < Day(DOB))

AgeMonths = Mod(12 + Month(Today) - (Day(Today) < Day(DOB)) -
Month(DOB);12)

Obviously this has not been stress tested and maybe it breaks down -
give it a shot.
--
Dan
Using
FMP7.03, WinXP SP2




Reply With Quote
  #4  
Old   
Al Partridge
 
Posts: n/a

Default Re: Displaying age from birthdate - 08-25-2005 , 12:42 PM



Maybe I'm missing something here, but this simple calculation has always
seemed to work for me where Birthdate would be the name of the field
containing the person's birthday date. The calculation result should be
Number.

Calculation Field Age=
Year(Today) - Year(Birthdate) - If(Today< Date(Month(Birthdate),
Day(Birthdate), Year(Today)),1,0)

Of course in v7 you would replace the Today function with the
Get(CurrentDate) function thus:

Calculation Field Age=
Year(Get(CurrentDate)) - Year(Birthdate) - If(Get(CurrentDate)<
Date(Month(Birthdate), Day(Birthdate), Year(Get(CurrentDate))),1,0)

Does anyone know of a reason why this would not do the trick or why this
should not be used? I would like to hear some feedback.

Al

"Rick Altman" <rick.a (AT) NOSPAMaltman (DOT) com> wrote

Quote:
I am attempting to create a simple display of a person's age from his or
her
birthdate. I want the display to be in the form of

17y 5m

and I am running into difficulty. Here is the formula as I have devised
it,
with Birthdate being a manually-entered date:



Let (Age=((Get(CurrentDate)-Birthdate)/365);
Int(Left(Age;2)) & "y " & Int(Right(Round(Age;1);1)*(12/10)) & "m")

//This long function does the following:
//1. Defines a variable that is a person's age, based on Birthdate
//2. Pulls out the first two digits as the year
//3. Pulls out the last digit and converts it from decimal to month



The conversion to y/m display fails with various dates. For instance, if
you
were to enter "8/1/03", the display would return 2y 2m. If anyone knows
why
this is happening, or knows of a better formula for accomplishing this
task,
I would appreciate hearing from you.




Rick A.
Pleasanton, CA





Reply With Quote
  #5  
Old   
Al Partridge
 
Posts: n/a

Default Re: Displaying age from birthdate - 08-25-2005 , 01:28 PM



Sorry. I missed the part about needing to display the months. This calc
will only show years. Al

"Al Partridge" <alp787 (AT) verizon (DOT) net> wrote

Quote:
Maybe I'm missing something here, but this simple calculation has always
seemed to work for me where Birthdate would be the name of the field
containing the person's birthday date. The calculation result should be
Number.

Calculation Field Age=
Year(Today) - Year(Birthdate) - If(Today< Date(Month(Birthdate),
Day(Birthdate), Year(Today)),1,0)

Of course in v7 you would replace the Today function with the
Get(CurrentDate) function thus:

Calculation Field Age=
Year(Get(CurrentDate)) - Year(Birthdate) - If(Get(CurrentDate)
Date(Month(Birthdate), Day(Birthdate), Year(Get(CurrentDate))),1,0)

Does anyone know of a reason why this would not do the trick or why this
should not be used? I would like to hear some feedback.

Al

"Rick Altman" <rick.a (AT) NOSPAMaltman (DOT) com> wrote in message
news:7-qdnci5NpWj_3PfRVn-uA (AT) comcast (DOT) com...
I am attempting to create a simple display of a person's age from his or
her
birthdate. I want the display to be in the form of

17y 5m

and I am running into difficulty. Here is the formula as I have devised
it,
with Birthdate being a manually-entered date:



Let (Age=((Get(CurrentDate)-Birthdate)/365);
Int(Left(Age;2)) & "y " & Int(Right(Round(Age;1);1)*(12/10)) & "m")

//This long function does the following:
//1. Defines a variable that is a person's age, based on Birthdate
//2. Pulls out the first two digits as the year
//3. Pulls out the last digit and converts it from decimal to month



The conversion to y/m display fails with various dates. For instance, if
you
were to enter "8/1/03", the display would return 2y 2m. If anyone knows
why
this is happening, or knows of a better formula for accomplishing this
task,
I would appreciate hearing from you.




Rick A.
Pleasanton, CA







Reply With Quote
  #6  
Old   
Helpful Harry
 
Posts: n/a

Default Re: Displaying age from birthdate - 08-25-2005 , 04:03 PM



In article <dqnPe.21654$0U6.617@trnddc09>, "Al Partridge"
<alp787 (AT) verizon (DOT) net> wrote:

Quote:
Maybe I'm missing something here, but this simple calculation has always
seemed to work for me where Birthdate would be the name of the field
containing the person's birthday date. The calculation result should be
Number.

Calculation Field Age=
Year(Today) - Year(Birthdate) - If(Today< Date(Month(Birthdate),
Day(Birthdate), Year(Today)),1,0)

Of course in v7 you would replace the Today function with the
Get(CurrentDate) function thus:

Calculation Field Age=
Year(Get(CurrentDate)) - Year(Birthdate) - If(Get(CurrentDate)
Date(Month(Birthdate), Day(Birthdate), Year(Get(CurrentDate))),1,0)
You should replace "Today" with Status(CurrentDate) in older versions
of FileMaker as well.

"Today" is rather useless since it is only really a Global field that
is calculated when opening the FileMaker application, meaning if you
leave the application on past midnight it returns the wrong date. This
is obviously going to be a problem in a server environment where
FileMaker is left running all day, every day. (Of course, the other
side of the coin is that it can sometimes be handy to know the date the
FileMaker application was started.)

Status(CurrentDate) / Get(CurrentDate) is calculated whenever you call
the function, so it always gives the correct date (assuming the
computer's system date is set correctly!).



Quote:
Does anyone know of a reason why this would not do the trick or why this
should not be used? I would like to hear some feedback.
Here's a slightly simpler version:

Year(Get(CurrentDate)) - Year(BirthDate)
- (Get(CurrentDate) < Date(Month(Birthdate), Day(Birthdate),
Year(Get(CurrentDate))))

You don't actually need the "If" statment since the Boolean Logic means
that "Get(CurrentDate) < OtherDate" will calculate as 1 when it's true
and 0 when it's false.



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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.