Jump to content

This topic is 8244 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi,

I got a really long age calculation from FileMaker's web site which returns results in a "36Years, 6Months, 14Days" format. This is working ok but isn't the best solution for my data base. I would actually like two results based off of my birthdate field; one that returns just how many years old the person is (with out the months and days), and another that returns an "age nearest birthday" result. For example, if the persons birthdate is 1/1/1980, on July 2nd of 2002 they would be 23, age nearest birthday. But on June 29th 2002 they would still be 22. Does this make sense?

Here is the calculation I got from FileMaker:

NumToText(Year(Today) - Year(Birthdate) - If(Today<Date(Month(Birthdate),Day(Birthdate),Year(Today)), 1, 0))&"Years,"&NumToText(Mod(Month(Today) - Month(Birthdate) + 12 - If(Day(Today) < Day(Birthdate), 1, 0), 12))&"Month,"&NumToText(Day(Today) - Day(Birthdate) + If(Day(Today) >=Day(Birthdate), 0,If(Day(Today- Day(Today)) < Day(Birthdate),Day(Birthdate),Day(Today- Day(Today)))))&"Days"

Any help would be greatly appreciated.

Joe

confused.gif

Posted

AOL#Leeftijd Calculation (Text) = Int(((Year(Today)*12+Month(Today)) -(

Year(AOL_DAT_geboorte)*12+Month(AOL_DAT_geboorte)))/12) & " jaar en " &

Mod(((Year(Today)*12+Month(Today)) -(

Year(AOL_DAT_geboorte)*12+Month(AOL_DAT_geboorte)));12)& " mnd"

This one gives you the age in years and months. Use it myself.

geboorte=birthdate

jaar= year

mnd = month(s)

leeftijd = age

(that's a short lesson in dutch..)

harryk

Posted

This solution looks funny but it seems to work:

I created 6 new fields you would use at least some of yours:

Birthdate Date Field

NextBirthday Calculation (Number) Unstored calculation

= Case(Month(Status( CurrentDate)) < Month(Birthdate),Year( Status( CurrentDate)) - Year(Birthdate),Year( Status( CurrentDate)) -

Year(Birthdate) + 1)

Years Calculation (Number) = Year(ALL)-1

Months Calculation (Number) = Month(ALL)-1

Days Calculation (Number) = Day(ALL)-1

ALL Calculation (Date) = Status( CurrentDate) - Birthdate

The odd part is formating the ALL calculation as a Date.

You could then combine your calculation to say

Years &"Yrs" & Months& "Months"&Days&"Days"

Note: Use Status(CurrentDate) instead of Today.

Posted

Hey, thanks for the replies guys. I haven't had a chance to fiddle with them. Do either of your calculations result in the "age nearest birthday" solution I was looking for?

Joe grin.gif

Posted

>age nearest birthday?

My solution does not really what you want; it outputs the years and the months for example <22 years 7 mnth>. If you fiddle around a bit with this calculation you might round the result to 23 if mnth>6, else 22. I just give you the start, perhaps you can finish it your way..

Posted

In theory, one pretty slick way to do it is like this. I've done similar things, but not exactly the same.

What you wnant to do is convert your date to an integer, so that you can round it. So...

daynumber = (divide the current day by (the date number of the day before the first day of the next month)) + current month

then...

bdaynumber = the same, but with their birthday

then...

next = mod(12, bdaynumber + 12 - daynumber)

last = mod(12, daynumber + 12 - bdaynumber)

if next is a smaller number, the next birthday is closer, if last is smaller, the last birthday is closer

Make sense?

This topic is 8244 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.