Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted (edited)

Solution / : Birthday Calculator ;-)

Description:

WARNING ? THIS IS A GREAT SOLUTION IF 1-2-3 DAYS ERROR IS NO PROBLEM !! SORRY I WAS WRONG !!!

Calculates Your Age in years

calculates Your exact age in years months and days and

calculates when the next PARTY is on !

Just a little fun out of my last sample file

Working Under:

Solution Status: Beta

Pre-requisites: FMP 7 or FMP 7 Advanced

Author(s): Ohgo_Ohgo

Date: 01/22/07

Credits: -

Instructions / Other Info: uses only native FMP calendar so should be exact ( not 365,25 years etc )

Should work in any System Time Date settings

and maybe even works in non Gregorian Calendars on Mac :;)

Critic and feedback welcome ! Ohgo_Ohgo

Disclaimer:

FM Forums does not endorse or warrantee these files are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify.

BirthDayCalculator.zip

Edited by Guest
add warning !
Posted

I have made a small bet with myself that I will break any calculation of the "years, months, days" type.

Here goes this one:

Born: July 1, 2006

Today: September 1, 2007

Result: 1 Years 2 Months 3 Days

Posted

Does ugly count? Yes I know it does but I simply can't resist a challenge. I could cheat and pull in some techniques recently gleaned from you but it wouldn't count as mine. I've been playing with this one for awhile now and I do NOT believe you can break it. If I am wrong, I win anyway. Such an opportunity doesn't come along often. So please, Squire Comment, make my day by making me start afresh in my approach. Break it. I have no pride when it comes to learning. Result is text and Unstored. No custom function required ...

Let ( [

BDnow = Date ( Month ( Born ) ; Day ( Born ) ; Year ( Today ) ) ;

y = Year ( Today ) - Year ( Born ) - ( Today < BDnow ) ;

yDate = Date ( Month ( Born ) ; Day ( Born ) ; Year ( Born ) + y ) ;

m = Let ( num = If ( Month ( yDate ) > Month ( Today ) ; 12 - Month ( yDate ) + Month ( Today ) ; Month ( Today ) - Month ( yDate ) - ( Day ( yDate ) > Day ( Today ) ) ) ;

num - ( Date ( Month ( yDate ) + num ; Day ( yDate ) ; Year ( yDate ) ) > Today ) ) ;

mDate = Date ( Month ( yDate ) + m ; Day ( yDate ) ; Year ( yDate ) ) ;

d = Today - mDate ] ;

If ( y ; y & " year" & If ( y > 1 ; "s" ) & " " ) &

If ( m ; m & " month" & If ( m > 1 ; "s" ) & " " ) &

If ( d ; d & " day" & If ( d > 1 ; "s" ) ) )

I almost missed this post! I may wish I had. :wink2:

LaRetta

Posted

I have made a small bet with myself that I will break any calculation of the "years, months, days" type.

Hi Comment !

First congratulation! YOU won ! Beer, Wine. Whiskey ...all on me ;-)

Now I’m not sure should I delete my 2 sample files ;) or change them into Alpha...

funny thing is it works fine for quite a lot of dates that’s why I did not realise when I tested my sample counting fingers ;-)

I am still trying to figure out ( for me to understand ) what is wrong.

it looked so easy ! May be leave the sample as a demonstration how not to do it ;-)

please give me some time to confess and find out....

I think it's the problem that 30 days day difference are not always a month depending on what month of the year you look at ??

thx Ohgo_Ohgo

Posted

...funny thing is it works fine for quite a lot of dates ...

This is the problem with testing dates. There are so many configurations that it requires one of the true Date Masters ( there are only a few in my opinion ). I wouldn't delete your post. Every thread is a learning tool; my calc as well. On FM Forums, we all win when we explore. Dates are my favorite playground but I do not master them. Yet.

UPDATE: That is why having a calc tested is such a great opportunity here. My conjecture was the date must be jumped forward at each break so FM could adjust. Only true dates increment properly ( that's the purpose of yDate and mDate). But conjecture is not theory.

Posted

we all win when we explore

First thanks for the good words !!

I try to understand Your formula but I have never seen

y = Year ( Today ) - Year ( Born ) - ( Today < BDnow )

what does that mean ?

ahhhh......is that a "logic" 0 or 1

0 or 1 substracted ?? that's great ! saves a whole if statment !?

Posted

First, the bet is with myself - this is not a Break-Your-Calc-While-U-Wait service. I just wanted to point out (again) that the concept is meaningless.

However, since I am here already:

Let's have:

Born: Feb 1 2007

Today: Mar 2 2007

The result is: 1 month 1 day

OK, that seems fair enough: we have had the entire month of February, and one day of March. Looks like your calc doesn't count the ending day, which is fine with me (as long as it's stated).

So now, if we move the starting day one day backwards, what should the result be? I would expect "1 month 2 days", right? But no, it returns "30 days". So what happened to February?

Posted

Ohgo, we don't NEED the 'If' in front (nor Case for that matter) on boolean. If the condition is true it produces a 1. It is a powerful concept which goes well beyond producing a simple 1.

"Break-Your-Calc-While-U-Wait service." I pictured you rolling up your sleeves, Michael, and saying, "C'mon, give me your best shots" so I did. :giggle:

It is just difficult to believe that we can put men on the moon (or in studios) and STILL not force the universe to fit our human logic. And still, even with that final I-finally-get-it logic fresh in my mind (and on paper in front of my eyes), a part of my brain is already saying, "Okay fine. Then simply add a final test that, if the number of days is less than the prior month's total days, add a month and deduct all days." But I've the feeling that, even if I added this test, it would then skew somewhere else. Giving up is difficult.

Now THIS is a powerful lesson for me. Thank you for breaking it even though you weren't in the calc-breaking business. Year, month, day calculations are like horseshoes and hand grenades - close is the best we can do. And I'm pasting horseshoes and hand grenades on my wall as reminder.

LaRetta :wink2:

Posted

I just wanted to point out (again) that the concept is meaningless.

we can put men on the moon and STILL not force the universe to fit our human logic.

And I'm pasting horseshoes and hand grenades on my wall

Halo comment please give me back my beer,wine,whiskey ! ;-)

And now I bet you ! BREAK IT !

Halo LaRetta fly with me to the moon and take Your horseshoes and hand grenades from the wall first ;-)

I found the Solution ! ( or I make myself an even bigger idiot in front of everybody - I am scared !)

AgeLong(bithday;today)

Let ([

Today = today; // set today = Get (Currentdate) if you dont have a "today" field and delete today from the Function Parameter

BDayThisYear = Date (Month (Birthday) ; Day(Birthday) ; Year (Today) );

BDYNotYet = If ( BDayThisYear > Today ; 1 ;0 );

Y = Year (Today) - Year (Birthday) - BDYNotYet;

DNotYet = If (Day(Today) ≥ 1 and Day(Today) < Day(Birthday) ; 1 ;0 );

M = If ( BDYNotYet;

If (DNotYet ; 12 - Month (Birthday) + Month (Today) -1 ; 12 - Month (Birthday) + Month (Today) );

If ( DNotYet ; Month (Today) - Month (Birthday) -1 ; Month (Today) - Month (Birthday) ) );

DLastMonth = (Date ( Month (Today) ; Day (1) ;Year (Today)) -1 )- Date ( Month (Today) - 1; Day (1) ;Year (Today)) +1;

M1 = If (DLastMonth ≥ Day(Birthday) ; 1 ;0 );

BdayLastMonth = If ( M1;Date (Month (Today) -1; Day (Birthday) ; Year (Today));Date (Month (Today); Day (1) ; Year (Today)));

BdayThisMonth =Date (Month (Today) ; Day (Birthday) ; Year (Today));

BDMonthNotYet = BdayThisMonth > Today;

LastBDay = If ( BDMonthNotYet;BdayLastMonth;BdayThisMonth);

D = Today-LastBDay

] ;

Y & " year" & If ( y > 1 ; "s" ) & " " & M & " month" & If ( m > 1 ; "s" ) & " " & D & " day" & If ( d > 1 ; "s")

)

LaRetta I think you where on the right track before !

Just FMP Date ( Month(today)-1 ;Day(today);Year (today))calculates wrong if february is involved.

eg. 30.3.2007

Date (Month(3)-1;Day(30);year(2007)) result 2.3.2007 should be 1.3.2007

eg. 31.3.2007

Date (Month(3)-1;Day(31);year(2007)) result 3.3.2007 should be 1.3.2007

Date(M;D;Y) works fine the rest of the year

e.g 31.5.2007 - 1 month is 1.5.2007 this is right because there is no 31.4.2007 so it must go to the next 1 st of the next month.

BTW I did not "shorten" the Let statment so it's more clear what I want to do . Finding the last "monthly" Birthday and calculate the days until today.

Ok open for discussion Now!! Praise ;-) or Shame ;-( on me !

Posted

Oh, please...

Mar 1 - Feb 1 = 0 year 1 month 0 day

Mar 1 - Jan 31 = 0 year 1 month 0 day

Conclusion:

Feb 1 = Jan 31

But the failure is mine, not yours. I am trying to explain that you cannot measure time difference in years, months and days, but obviously I am not getting through.

Posted

Oh, please...

Mar 1 - Feb 1 = 0 year 1 month 0 day

Mar 1 - Jan 31 = 0 year 1 month 0 day

Conclusion:

Feb 1 = Jan 31

But the failure is mine, not yours. I am trying to explain that you cannot measure time difference in years, months and days, but obviously I am not getting through.

thanks for coming in comment !!

You are right 1 Feb is not 31 Jan but actually

31.Jan to 1.March = 1 month and

30 Jan to 1 March = 1 month and

29.Jan to 1.March = 1 month

But yes every month in this example has a different length of Days !! that’s the problem with months !

They have different length of days depend on there “occurrence” in the year !

Yes a problem ! Specially because even FMP has problems with it !! ( and I had mine !)

Ok sorry comment ( I know you are aware of that ) but may be interesting as a example for some other readers.

If born 31 .5.yyyyy on 30.4.yyyy you are not 11 month old only on 1. 5. because 31.4. is not available!

so days which are not available in a month are all moved to the 1. of the next month.

Think of the poor boy who has birthday on 29 february ?? after 40 years (for us ) he has only his 10 th birthday ???

The key to understand I think is that month are relative to the date and the whole month problem is only a definition we have to agree on.

( wishi washi for a technical person I know : a month is 28 days long aeh 29 aeh 30 aeh 31 - aeh you choose ;-) )

thanks very much for comment and LaRetta to lead me to a better understanding, now I work on the Next Party formula ( spins my head again ) so i can correct my initial mistakes !

rgds Ohgo_Ohgo

Posted

The key to understand I think is that month are relative to the date and the whole month problem is only a definition we have to agree on.

Exactly. That's why 'years, months and days' as such is meaningless. That "poor boy who has birthday on 29 february" can decide to celebrate on Feb 28, or Mar 1, or every 4 years - and no one can say which is correct and which is wrong.

×
×
  • Create New...

Important Information

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